物件導向104mid

 avatar
user_3763047219
c_cpp
a year ago
684 B
0
Indexable
Never
#include <iostream>
using namespace std;    //error1

class SuperStar{         //error2 class
    int id;
    int age;         //error3 «Øºc¤l
public:
    void Show(SuperStar );//error5 SuperStar
    int getID(){return id;}
    void Show(){cout<<"SuperStar No."<<getID()<<"say\"Hello!\""<<endl;}
    SuperStar(int n1=1, int n2=1){
        id=n1;age=n2;
    }

};//error7 ;

void SuperStar::Show(SuperStar obj){//error 4 ::
    cout<<"Superstar No."<<obj.getID()<<"say\"Hello!\""<<endl;
}


SuperStar s1(1,18);//error 4¡B6
SuperStar s2;

int main(){
    //int s1 = 2;
    s1.Show(s1);
    s1.Show();
    s2.Show(s2);
    s2.Show();
    return 0;
}