CornJer
Metal does cocaine.
2005 Mar 21 • 1531
36 ₧
|
Question: How does one execute code in all instances of a class?
Please remember that I am a newbie at C++, and the code may be wrong.
For example:
[code:1]
class animal
{
public:
int x;
int y;
int move()
{
x += 1;
y += 1;
}
}
class cat : class animal
{
public
int toes
int move()
{
x+=1
y+=2
toes = 6
}
}
cat Mrbonkers;
animal Rat;
animal dog;
[/code:1]
Yes, the cat class is inherrited from animal.
How do I execute the move() function in all three instances of the classes, without doing this:
[code:1]
Rat.move();
dog.move();
Mrbonkers.move();
[/code:1]
Any help would be appreciated.
If you jump high enough you'll hurt your ankles when you land.
|
|
|
|
≡
|
2006 Sep 26 at 14:49 UTC
|
|