注册 登录
编程论坛 C++教室

求指教 ,看不出这个关于类跟对象的代码的错误

空沃夫 发布于 2013-03-21 19:51, 360 次点击
程序代码:
#include <iostream.h>
class A
{
      public:
             A()
             {
                     m=0;
             }
             A(double i)
             {
                      m=i;
             }
             void print()
             {
                  cout<<m<<endl;
             }
             private;
             double m;
             };
void main ()
{
                  A a(5);
                  a.print();
                  a=10;
                  a.print();
}

求大神编译下,我用的是Dev,搞不懂它说的错是指哪里?,这堆是关于类型转换结构函数的初学者的代码。。
1 回复
#2
qunxingw2013-03-21 21:33
程序代码:
#include <iostream.h>
class A
{
      public:
             A()
             {
                     m=0;
             }
             A(double i)
             {
                      m=i;
             }
             void print()
             {
                  cout<<m<<endl;
             }
      private://;
             double m;
             };
void main ()
{
                  A a(5);
                  a.print();
                  a=10;
                  a.print();
}
1