Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

EvilCrap

why dont this work?!

This topic is 6108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
"private virutal Act()"

Maybe cause it''s private.....
and when you derive classes they don''t appear....


jeez


Pac

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
hmm sorry maybe my original post wasnt clear
...
where CDog, and CCat, have Base Class CAnimal and private virtual Act() in common.
...
??

Share this post


Link to post
Share on other sites
hmm sorry maybe my original post wasnt clear
...
where CDog, and CCat, have Base Class CAnimal and private virtual Act() in common.
...
??

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!!"
======================
*/

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!