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?
3 Respuestas
+ 1
@adam it's c++, not java
0
1st line of int main should be myClass myObj = new myClass() I believe.
0
https://code.sololearn.com/cwW20249UKO3/?ref=app
Itried your code, it's output "SoloLearn".