Greemax Posted May 31, 2013 at 06:12 PM Report #510326 Posted May 31, 2013 at 06:12 PM Boas Estou a fazer uma applicação para testar projecteis para futuramente utilizar num jogo. Por alto tenho algo do género: class Object { public: //variaveis std::string directory; Object(std::string _dir): directory(dir){} //funcções }; //noutro headder class Player : public Object { public: //variaveis Player(std::string _dir): directory(dir){} //funções } Eu utilizo a Classe Object para criar o projectil e a player para o Player. Eu gostaria de saber, se de alguma forma posso utilizar na classe Player o Constructor da classe Object. Eu ja experimentei desta forma e até sem por o constructor na classe Player, mas não tá a dar. Como está, diz que o directory não é um membro estatico de Player e que Object não tem um "default constructor".
HappyHippyHippo Posted May 31, 2013 at 06:20 PM Report #510329 Posted May 31, 2013 at 06:20 PM (edited) class Object { protected: std::string directory; public: Object(std::string dir): directory(dir){} }; class Player : public Object { public: Player(std::string dir) : Object(dir){} } Edited May 31, 2013 at 06:20 PM by HappyHippyHippo IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Greemax Posted May 31, 2013 at 07:01 PM Author Report #510337 Posted May 31, 2013 at 07:01 PM Obrigado, está operacional.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now