why dont this work?!
im trying to do this thing with virtual functions and stuff.
where CDog and CCat have base class CAnimal, and private virutal Act() in common:
CCat Cat;
CDog Dog;
CAnimal **Animal = NULL;
Animal = new CAnimal*[2];
Animal[0] = &Dog
Animal[1] = &Cat
Animal[0].Act();//err
Animal[1].Act();//err
when i call .Act(), i get this compiler error:
//error C2228: left of ''.Act'' must have class/struct/union type
How can i call these, or am i doing this entire thing wrongly?
"private virutal Act()"
Maybe cause it''s private.....
and when you derive classes they don''t appear....
jeez
Pac
Maybe cause it''s private.....
and when you derive classes they don''t appear....
jeez
Pac
jeez?~!?!?!
you SAY jeez?!!?!?!?
well, mr (knowetall), i happened to have figured it out...
and it should be ->Act();
DUHHHH!!! MVC++ is so dumb, i swear, you think it could spot that.
i swear i cant beleive i wasted so much brain power on dat mistype.
you SAY jeez?!!?!?!?
well, mr (knowetall), i happened to have figured it out...
and it should be ->Act();
DUHHHH!!! MVC++ is so dumb, i swear, you think it could spot that.
i swear i cant beleive i wasted so much brain power on dat mistype.
hmm sorry maybe my original post wasnt clear
...
where CDog, and CCat, have Base Class CAnimal and private virtual Act() in common.
...
??
...
where CDog, and CCat, have Base Class CAnimal and private virtual Act() in common.
...
??
hmm sorry maybe my original post wasnt clear
...
where CDog, and CCat, have Base Class CAnimal and private virtual Act() in common.
...
??
...
where CDog, and CCat, have Base Class CAnimal and private virtual Act() in common.
...
??
I could answer the question.
But it wouldn''t be helpful to do so.
Your compiler ships with documentation, including semi-detailed explanations of the error messages it produces.
Learn how to use them. It will serve you well.
But it wouldn''t be helpful to do so.
Your compiler ships with documentation, including semi-detailed explanations of the error messages it produces.
Learn how to use them. It will serve you well.
HeHe,
Gotta love it when people think that a $1,600 program is stupid!
/*
======================
Pop me an email
Here
"In Windows, the only thing opposing safe mode would be... Unsafe mode....??"
- Me
"hmm, I know the slogans "will work for food" and "will work for free", but "will pay for work I do" seems just a bit sick "
- MirekCz
"I want to do this huge ass multiplayer first person space sim rpg strategy game!!"
======================
*/
Gotta love it when people think that a $1,600 program is stupid!
/*
======================
Pop me an email
Here
"In Windows, the only thing opposing safe mode would be... Unsafe mode....??"
- Me
"hmm, I know the slogans "will work for food" and "will work for free", but "will pay for work I do" seems just a bit sick "
- MirekCz
"I want to do this huge ass multiplayer first person space sim rpg strategy game!!"
======================
*/
Animal[0] and Animal[1] are pointers, so you have to use the -> operator to access the methods.
CCat Cat;
CDog Dog;
CAnimal **Animal = NULL;
Animal = new CAnimal*[2];
Animal[0] = &Dog
Animal[1] = &Cat
Animal[0]->Act(); // should work now
Animal[1]->Act(); // should work now
No, HTML is not an OO language.
CCat Cat;
CDog Dog;
CAnimal **Animal = NULL;
Animal = new CAnimal*[2];
Animal[0] = &Dog
Animal[1] = &Cat
Animal[0]->Act(); // should work now
Animal[1]->Act(); // should work now
No, HTML is not an OO language.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement