C++请问这代码哪里错了?error C2062: type 'int' unexpected
#include<iostream.h>classMy{public:voidp();My(intx,inty,intz);privtae:intsum;inta,b,c...
#include <iostream.h>
class My
{
public: void p();
My(int x,int y,int z);
privtae:
int sum;
int a,b,c;
};
My::My(int x,int y,int z)
{
a=x;
b=y;
c=z;
sum+=a+b+c;
}
void My::p()
{
cout<<sum<<endl;
}
void main()
{
My M1(1,2,3);
M1.p();
My M2(4,5,6);
M2.p();
M1.p();
} 展开
class My
{
public: void p();
My(int x,int y,int z);
privtae:
int sum;
int a,b,c;
};
My::My(int x,int y,int z)
{
a=x;
b=y;
c=z;
sum+=a+b+c;
}
void My::p()
{
cout<<sum<<endl;
}
void main()
{
My M1(1,2,3);
M1.p();
My M2(4,5,6);
M2.p();
M1.p();
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询