gpt4 book ai didi

C++自定义类返回

转载 作者:行者123 更新时间:2023-11-28 03:12:00 25 4
gpt4 key购买 nike

<分区>

我定义了一个类,

目标:模拟字符串,但功能更多

class ex_char
{
public:
ex_char(char *input):len(strlen(input)){strcpy(str,input);}
...functions...
private:
char *str; //where the char array is saved
int len; //length of the char array
};

对于普通的字符数组,我们可以使用:

char charray[10]="String";
cout<<charray;

显示char数组的内容

但是我怎样才能显示我类(class)的 str 属性的内容呢

cout<<excharray;

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com