0

Help

#include <iostream> #include <string> using namespace std; class myClass { public: string name; }; int main() { myClass myObj; myObj.name = "SoloLearn"; cout << myObj.name; return 0; } when I try to run this it says- 'myObj' does not name a type, 'cout' does not name a type, and expected unqualified-id before return. help?

16th Apr 2018, 1:16 AM
Sir
3 ответов
+ 1
@adam it's c++, not java
16th Apr 2018, 8:59 AM
Amir Galanty
Amir Galanty - avatar
0
1st line of int main should be myClass myObj = new myClass() I believe.
16th Apr 2018, 1:53 AM
Adam
Adam - avatar
0
https://code.sololearn.com/cwW20249UKO3/?ref=app Itried your code, it's output "SoloLearn".
16th Apr 2018, 1:55 AM
Amir Galanty
Amir Galanty - avatar