Saturday, August 14, 2010

Multiple Inheritance

,
Multiple Inheritance:-I n the multiple Inheritance there will be many base classes and there is only one derived class which derives from all the base classes.

Example:-
class A
{
A()
{
Cout<<”I m in A”;
}
};
Class B
{
B()
{
Cout<<”I m in B”;
}
};
class C
{
C()
{
Cout<<”I m in C”;
}
};
Class D:public A,public B,public C
{
D()
{
Cout<<”I m in D”;
}
};
Voi d main()
{
D d;
}

Output:-
I m in A
I m in B
I m in C
I m in D
Read more →

Single Inheritance

,
Single Inheritance:-In the Single Inheritance there will only one base class and only one derived class.It should be like this.
Example:-
class A
{
A()
{
Cout<<”I m in A”;
}
};
Class B:public A
{
B()
{
Cout<<”I m in B”;
}
};
Voi d main()
{
B b;
}

Output:-I m in A
I m in B
Read more →

C++ Description

,
Read more →

Difference between C and C++

,
Read more →

Thursday, July 22, 2010

What is C++ Constructor, and How to use Constructor with Inheritance

,
A constructor is a special type of function whose functionality is to intialize the data members of a class at a time of object creation.so that it is also called automatic intialization of objects.

Properties of a constructor:-
1.)It is invoked automatically at a time of the creation of object.so that the data members are intialized.

2.)It has neither return type nor void type.

3.)The name of a constructor and class should be identical.

4.)It should be declared on a public section.


Types of aconstructor:-

1.)Default Constructor.
2.)Copy Constructor.
3.)Parametrised constructor
Read more →