No errors are generated, but nothing is printed when I run the code. Help?
class NatalieClass{ public:
void setName(string x){
x = name;
}
string getName(){
return name;
}
private:
string name;
};
int main(){
NatalieClass ob1;
ob1.setName("Hello World");
cout << ob1.getName();
return 0;
}
The function is supposed to print "Hello World" but instead nothing is printed.
Aucun commentaire:
Enregistrer un commentaire