-
1 Attachment(s)
class string error
Code:
#include<iostream>
#include<cstdlib>
#include<string>
class GradeBook{
private:
string name;
public:
void setName(string nameofCourse){
nameofCourse = name;
}
string getName(){
return name
}
};
int main(){
GradeBook b1;
string cname;
getline(cin , cname);
b1.setName(cname);
cout << "Welcome to GradeBook for " << b1.getName() << endl;
system("pause");
return 0;
}
Attachment 15782
I am trying this code and error message.
Can you please check the issue?
-
Well I've identified error. Thanks for all
-
Code:
void setName(string nameofCourse){
nameofCourse = name
}
Shouldn't this be:
Code:
void setName(string nameofCourse){
name = nameofCourse;
}
?
-
Yeah! there were two errors. One as you are indicating to and the other I haven't used using namespace std;