Jump to content
  • Advertisement

Archived

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

ironfroggy

multi classes with identical method

This topic is 6343 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

say i have class A. and i have classes B and C inherited from A. and i have a pointer P that could point to either a B or a C type object. And i have method D(int E); in both B and C. I then do this: P->D(1); will this call the method of the B or C type object, whichever it is pointing too at the time? psst.. did you see me post this on the graphics board by accident? oops! i forgot where i was..

Share this post


Link to post
Share on other sites
Advertisement
let's see....

class A
{
/*...*/
virtual void fnc(int a) = 0;
/*...*/
};
class B : public A
{
/*...*/
virtual void fnc(int a) {/*whatever u want to do.*/};
/*...*/
}
class C : public A
{
/*...*/
virtual void fnc(int a) {{/*whatever u want to do.*/};
/*...*/
}

so u can do the following:

void someOtherFnc(A* pA);
{
pA->fnc(10);
}

but u cant do:
//...
A a; // compiler error: pure virtual members in a; u
// can't declare instances of A



Edited by - teneniel on January 14, 2001 12:31:33 PM

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!