构造函数无法运行 [英] constructor does not run
本文介绍了构造函数无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不明白,因为当您创建 Users类的对象时,不会打印包含构造函数的消息。
I do not understand because when you create an object of the "Users" class not the message is printed containing the constructor.
class users
{
public:
users();
private:
int i;
};
users::users ()
{
cout<<"hello world";
}
int main ()
{
users users1();
return 0;
}
推荐答案
users users1();
不声明个用户的对象
类,它声明一个不带参数的函数,并返回 users
类的对象。要声明对象,请使用:
doesn't declare an object of the users
class, it declares a function that takes no arguments and returns an object of the users
class. To declare an object, use:
users users1;
这篇关于构造函数无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文