#include<iostream.h>
class f{
private:int x=0,y=0;
public:void f1(int a,int b){x=a;y=b;}
void get(){cout<<x<<','<<y<<endl;}
};
main(){
f a;
a.f1(1,3);
a.get();
}
PRIVATE:INT X=0,Y=0;错误。
数据成员声明时不允许直接赋值
#include<iostream.h>
class f{
private:int x=0,y=0;
public:void f1(int a,int b){x=a;y=b;}
void get(){cout<<x<<','<<y<<endl;}
};
main(){
f a;
a.f1(1,3);
a.get();
}
#include<iostream.h>
class f{
private:int x=0,y=0;
public:void f1(int a,int b){x=a;y=b;}
void get(){cout<<x<<','<<y<<endl;}
};
main(){
f a;
a.f1(1,3);
a.get();
}
PRIVATE:INT X=0,Y=0;错误。
数据成员声明时不允许直接赋值