错误是什么,我将其删除?请回答!!! [英] what is the error and i remove them? pls answer!!!

查看:92
本文介绍了错误是什么,我将其删除?请回答!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class student
{
 public:
 int x=10;
 char y;
};
   void main()
{
     student abc;
     cout<<abc.x;
}



添加了< pre>标签以提高可读性-Code-o-mat [/EDIT]



Added <pre> tags for better readability - Code-o-mat [/EDIT]

推荐答案

初始化构造函数中的成员变量.
所以代替这个:
Initialize member variables in the constuctor.
So instead of this:
class student
{
public:
  int x=10;
}



做这样的事情:



do something like this:

class student
{
public:
  int x;

  student()
  {
    x=10;
  }
};


这篇关于错误是什么,我将其删除?请回答!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆