Even though I know the cause of error,but I don't know,why the __cout << "hii"__ line don't work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Even though I know the cause of error,but I don't know,why the __cout << "hii"__ line don't work?

Is this an compile error or run time error, May I get an output,if it is an runtime error https://sololearn.com/compiler-playground/cgxsdTB5a0NX/?ref=app

15th Feb 2024, 12:25 PM
Yogeshwaran P
Yogeshwaran P - avatar
2 Answers
+ 2
C++ is a compiled language. The code needs to be compiled first before it can run. Your class instantiation raises an error which prevents the program from compiling. That's why the cout<<"hii"; is not printed.
15th Feb 2024, 12:58 PM
Bob_Li
Bob_Li - avatar
+ 2
Read the error message: myClass::myClass() is private! The constructor needs to be public so the object can be created.
15th Feb 2024, 12:32 PM
Lisa
Lisa - avatar