0
Compilation error and nested classes
Why is the code below returning a compilation error? #include <iostream> using namespace std; class engine { public: bool run() { starter starter; starter.start(); return starter.isRunning(); } class starter { public: void start() { running=true; } bool isRunning() { return running; } private: bool running=false; }; }; int main() { engine engine; cout << engine.run; }
2 Respuestas
+ 1
You forgot the () after run:
cout << engine.run();
Also consider making your class start with a capital, this just hurts my eyes :(
So engine -> Engine and starter -> Starter
0
Thanks, it works now. When I resume working with the language, I'll make my code neater and more organized.