How to define a derived class, C/C++ Programming

Assignment Help:

How to define a derived class ?

A singly inherited derived class id defined by writing :

  • The keyword class.
  • The name of the derived class .
  • A single colon (:).
  • The type of derivation ( private , protected, or public ).
  • The name of the base, or parent class.
  • The remainder of the class definition.

e.g.

                class A

                 {

                  public :

                                                int public_A;

                                                void public_function_A();                           

  private :

                                                int pri_A;

                                                void private_function_A();

  protected :

                                                int protected_A;

                                                void protected_function_A();

 

  };

 

class B : private  A

 {

                  public :

                                                int public_B;

                                                void public_function_B();                            

       private :

                                                int pri_B;

                                                void private_function_B();

};

class C : public  A

 {

  public :

                                                int public_C;

                                                void public_function_C();                            

        private :

                                                int pri_C;

                                                void private_function_C();

 };

class D : protected A

 {

                  public :

                                                int public_D;

                                                void public_function_D();                                

                  private :

                                                int pri_D;

                                                void private_function_D();

                 };

A derived class always have all of the member members from its base class. You cannot "subtract" anything from a base class. Though, accessing the inherited variables is a dissimilar matter. It is also important to understand the privileges that the derived class has insofar as access to members of its base class are concerned. In other words, just because you happen to derive a class does not mean that you are automatically granted complete and unlimited access privileges to the members of the base class. to understand this you must look at the dissimilar types of derivation and the effect of each one.

 


Related Discussions:- How to define a derived class

Area under curve. , Write a program to find the area under the curve y = f(...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Data structure and algorithm, implement two stacks in one array A[1...n] in...

implement two stacks in one array A[1...n] in such a way that neither stack overflows unless the total number of elements in both stacks together is n. For this you need to produce

Described the scope resolution operator?, A: It allows a program to referen...

A: It allows a program to reference an identifier in global scope which has been hidden by another identifier along with the same name in the local scope.

Program, write a program for convert numbers upto 9 to alphabet?Eg.now ente...

write a program for convert numbers upto 9 to alphabet?Eg.now enter the inputis 666 means output is "0" lphabet

C program for function of count the interest , C Program for FUNCTION OF CO...

C Program for FUNCTION OF COUNT THE INTEREST float si(float,float,float); void main() {           float p=0,r=0,n=0,k=0;           clrscr();           printf("E

Write a c program to calculate the equation, Write a C program to calculate...

Write a C program to calculate the output Y for a given value of X for the following formula   Y=X 2 + 2X +3   #include stdio.h   void main()   {   char promt;   float y,x

#otto cycle, To get the efficiency of Otto cycle by C/C++.

To get the efficiency of Otto cycle by C/C++.

Flow chart, flow chart for calculating the volume of sphere

flow chart for calculating the volume of sphere

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd