[Solved] Abstract Classes

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
Xecantur
Gnoblar
Posts: 24
Joined: Fri Apr 19, 2013 5:07 am

[Solved] Abstract Classes

Post by Xecantur »

So it is my understanding that an Abstract class is one that has one or more pure virtual functions, and that a concrete class is a class where all of its methods are defined, I've also gathered that you can't instantiate an object of an Abstract class, however if you define all inherited virtual and pure virtual functions leading up to that class it becomes a concrete class and allows you to instantiate an object correct ?
Last edited by Xecantur on Fri Apr 26, 2013 1:13 am, edited 1 time in total.
User avatar
Faranwath
Halfling
Posts: 93
Joined: Mon Jul 09, 2012 2:19 pm
Location: Cuba
x 7

Re: Abstract Classes

Post by Faranwath »

C++'s abstract classes are somehow similar to Java's and C#'s interfaces: you cannot instantiate them, but they can have member variables (which you can't do in these languages). If some class derives from an abstract class and doesn't define all of the puree virtual member function the base class has, it becomes an abstract class also. Only when a class has a definition for all of its member function can it be instantiated.
Xecantur
Gnoblar
Posts: 24
Joined: Fri Apr 19, 2013 5:07 am

Re: Abstract Classes

Post by Xecantur »

Thanks for clearing that up, they were starting to get on my nerves for awhile I kept wondering why it wasn't letting me instantiate an object for that class :P, I suppose it should be worth noting earlier in the tutorial wiki tutorials that if you plan to branch off you need to define all methods associated with those particular listener classes. :D
Post Reply