Classes, Abstract Data Types, Multiple Inheritance, etc

Submitted on: 1/3/2015 5:11:00 AM
By: telle (from psc cd)  
Level: Intermediate
User Rating: By 5 Users
Compatibility: Microsoft Visual C++
Views: 878
     This is basicly some notes i made for Classes, Abstract Data Types, Multiple Inheritance, and things like that


<--[if gte mso 10]>


With classes, everything is private, unless specified otherwise (Using the public: statement). When I say ‘private’, I mean everything declared under private is not seen by the programmer. Public declarations are seen by the programmer. Now, you should know that every time a class is created, a new instance is created. Within a class’s block scope you declare functions/constructor/deconstructor. It is not recommended to implant the code of functions for the class directly into the class, but by using the inline keyword. To define a function outside of a class’s block scope you use this format:

Class_Name::Function_Name(arguments) { //function code }

Now, there may come a time when you want a variable value to be the same through all the instances of the class, or you may just want to share the variable value through all the instances (for example, you might want to have a count of all the instances of a class). In order to do this, you use the static keyword. The format is as follows:

Static Variable_Type Variable_Name;

Here is an example that shows the use of a static variable in a class:

class STClass


int x; //private declaration

int y; //private declaration

static int count; //static declaration, private

inline counts()




STClass St1;

STClass St2;

Basically, count is going to equal 2.

Function Polymorphism in Classes

Polymorphism pretty much means many forms, and thus, function polymorphism means many forms of a function.

Function Polymorphism is there pretty much for the user to decide which function they want to use. Now, you should know, this really isn’t different from Function Overloading, which will be explained later on.

Abstract Data Type

Abstract Data Type’s require a pure function, or a NULL function. A format for an ADT is as follows:

vital void Function Name(arguments) = 0;

The format can vary.

Multiple Inheritance

Multiple Inheritance is the ability to transform an array of classes into one.

Here is an example on Multiple Inheritance:

Class This


int x;

int y;


Class That


int z;


Class ThisNThat : public This, public That


x = 100;

y = 200;

z = x + y;


Other 1 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.