esec.rom Posted June 7, 2013 at 09:24 PM Report #511596 Posted June 7, 2013 at 09:24 PM Boas, eu tenho uma Generalização onde tem uma class principal e duas sub class's. eu queria por uma variável na class principal e que tivesse aceso nas suas sub class's. mas a variável que pretendo adicionar não pode ser nenhum atributo nem método da class principal. alguém me pode sugerir uma solução?
HappyHippyHippo Posted June 7, 2013 at 09:47 PM Report #511603 Posted June 7, 2013 at 09:47 PM espera, o que percebi do teu problema foi : - tenho um relvado onde quero por um bovino mas não pode ser nem boi nem vaca é isso ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
pikax Posted June 7, 2013 at 09:58 PM Report #511604 Posted June 7, 2013 at 09:58 PM e' um pouco dificil perceber o que queres realmente... [irony] Podes ter 2 solucoes: -Usas o boost, decerteza que tem alguma funcao para isso. -Usas COM, as COM sao muito porreiras 🙂 [/irony] Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
esec.rom Posted June 7, 2013 at 10:17 PM Author Report #511606 Posted June 7, 2013 at 10:17 PM o que é COM
KTachyon Posted June 8, 2013 at 12:52 AM Report #511613 Posted June 8, 2013 at 12:52 AM #include <iostream> class Mae { protected: // É isto que queres? int variavel; }; class Filha : Mae { public: void setVariavel(int v); void printVariavel(); }; void Filha::setVariavel(int v) { variavel = v; } void Filha::printVariavel() { printf("%d\n", variavel); } using namespace std; int main(int argc, char *argv[]) { Filha f; f.setVariavel(5); f.printVariavel(); return 0; } “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
esec.rom Posted June 8, 2013 at 10:11 AM Author Report #511624 Posted June 8, 2013 at 10:11 AM obrigado a todos: resolvido
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