GitHub
1.
class BuckysClass{
public:
BuckysClass(){
cout << "this will get printed automatically";
}
void setName(string x){
name=x;
}
string getName(){
return name;
}
private:
string name;
};
BuckysClass bo;
//this will get printed automatically
2.
class BuckysClass{
public:
BuckysClass(string z){
setName(z);
}
void setName(string x){
name=x;
}
string getName(){
return name;
}
private:
string name;
};
BuckysClass bo("Lucky Bucky roberts");
cour << bo.getName();
BuckysClass bo2("Sally mcSalad");
cour << bo2.getName();
网友评论