+ 1

Classes, Headers

How can i access a classe's member functions declared in game.h from another class called skill in skill.h? Creating an object for game in skill.h does not work.

21st Dec 2016, 6:28 AM
Blood
Blood - avatar
1 Antwort
+ 6
In order for skill class to access the member function of game class. You would have to make the member function of game class public so that skill class will be able to call it. Then you would want skill class to inherit the function from game class. class game { public: game(){}; void do_somefunc() { cout << "Work" } }; class skill : public game { public: void somefunc(){} }; where your member function is declared somewhere in game, you then call the function in main through skill class int main() { skill s; s.do_somefunc(); return 0; } // outputs "Work"
21st Dec 2016, 6:39 AM
Hatsy Rei
Hatsy Rei - avatar