541代码吧 关注:3贴子:11
  • 1回复贴,共1
using namespace std;
class MyClass
{
public:
//MyClass (){x=0;y=0;};
MyClass(int a=0,int b=0);
void Print();
private:
int x,y;
};
MyClass::MyClass(int a,int b)
{
x=a;
y=b;
}
void MyClass::Print()
{
cout<<"x="<<x<<endl;
cout<<"y="<<y<<endl;
}
int main()
{
MyClass obj1,obj2(5,8);
//obj1.x=1;
//obj2.y=3;
obj1.Print();
obj2.Print();
system("pause");
return 0;
}


1楼2016-04-20 09:38回复
    没有分成3和文件啊


    来自iPhone客户端2楼2016-04-20 11:29
    回复