Oct 15, 2013 at 9:47pm Oct 15, 2013 at 9:47pm UTC
I'm looking at a class that is declared like the example below, can someone explain this declaration? Is this 2 classes foo and boo or is this boo of type foo and foo is the base class. Any help would be appreciated.
class foo boo
{
public:
} ;
Oct 15, 2013 at 10:22pm Oct 15, 2013 at 10:22pm UTC
If you were to write this with a colon (
: ) before the "boo" then the class foo would derive from boo.
e.g.
1 2 3 4 5 6 7
class boo{
int a;
};
class foo: boo{
int b;
//int a is also present as it is inherited from boo
};
If you were to write this but moving the "boo" to just after the closing curly brace then this would be declaring a variable boo of type foo.
e.g.
1 2 3 4 5 6 7 8
class foo{
}boo;
//is the same as this
class foo{
};
foo boo;
P.S... Maybe this should go in under the beginner forums?
Last edited on Oct 15, 2013 at 10:23pm Oct 15, 2013 at 10:23pm UTC
Oct 15, 2013 at 10:45pm Oct 15, 2013 at 10:45pm UTC
Thanks
Last edited on Oct 15, 2013 at 10:49pm Oct 15, 2013 at 10:49pm UTC