+ 1

can anyone help m out plz

i wrote this program to show student name and student id #include <iostream> #include <string> using namespace std; class myClass { public: string name; int id; }; int main() { myClass myObj; myObj.name = "SoloLearn"; myobj.id= 12345; cout << myObj.name<<"\t"<<myobj.id; return 0; } what is wrong????

28th Dec 2016, 5:18 PM
Rami Salim
Rami Salim - avatar
6 Respuestas
+ 1
Your variable name is off. Cout statement you are using myobj.id, should be myObj.
28th Dec 2016, 5:24 PM
Greg Ortiz
Greg Ortiz - avatar
+ 1
hey guys i got the answer this is the correct program #include <iostream> #include <string> using namespace std; class myClass { public: string name; int id; }; int main() { myClass myObj; myObj.name = "SoloLearn"; myObj.id= 167; cout <<" the name of the student is:::"<< myObj.name<<"\n\n\n\n\n the id of the student is :::"<<myObj.id; return 0; }
28th Dec 2016, 6:02 PM
Rami Salim
Rami Salim - avatar
0
compiler shows me errer output
28th Dec 2016, 5:24 PM
Rami Salim
Rami Salim - avatar
0
And as well as your assignment
28th Dec 2016, 5:24 PM
Greg Ortiz
Greg Ortiz - avatar
0
Sorry I didn't not get you
28th Dec 2016, 5:50 PM
Rami Salim
Rami Salim - avatar
0
Good that you found an answer that suits you, but that doesn't mean it's the right answer. C++ has a mechanism for handling formating the output which is why your code failed in the first place. http://www.cprogramming.com/tutorial/iomanip.html
29th Dec 2016, 9:52 AM
The Artist Formally Known as Jeremy
The Artist Formally Known as Jeremy - avatar