类在函数中第一次声明时只能调用构造函数嘛,不能调用其他函数?为什么不能直接调用其他函数啊,他上面显示没有可用成员,但是我明明在public那里定义了。28行的位置
根据网络搜索的资料,发现好像是需要先创建类,然后在调用它的方法,测试代码如下:
参考链接:
#include <iostream>
class T{
private :
char a;
int b;
double q;
public :
T(){
a='a';
b=2;
q=9.9;
}
T(T&t){
t.a='a';
t.b=3;
t.q=10;
}
void hehe(){
std::cout<<"hehe";
}
~T(){
}
};
//T::T(){
// a='a';
// b=2;
// q=9.9;
// }
//
//T::T(T&t){
// t.a='a';
// t.b=3;
// t.q=10;
//}
//
//void T::hehe(){
// std::cout<<"hehe";
//}
//
//T::~T(){
//
//}
int main(){
// https://blog.csdn.net/weixin_52028906/article/details/124513418
// https://www.runoob.com/cplusplus/cpp-classes-objects.html
// https://blog.csdn.net/a15322910600/article/details/105253549
T U ;
U.hehe();
return 0;
}
U 是什么