0
Please anyone tell me what is the problem in the code given below
4 Answers
+ 5
@Sourav I wrote name = x but you wrote name x
Correct it and then it will run fine
+ 4
#include <iostream>
using namespace std;
class MyClass{
private:
string name;
public :
MyClass (string sourav){
setname (sourav);
}
void setname(string x){
name = x;}
string getname(){
return name;}
};
int main() {
MyClass obj1("PSG");
MyClass obj2("BAYERN");
cout<<obj1.getname();
return 0;
}
+ 1
Yes thank you
0
Its still not working Kartikey sahu