MuruganAD.com
Murugan Andezuthu Dharmaratnam

  |  HOME   |  BLOG   |  DISCUSSION FORUM   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  



Articles - C++ Quick Refference : I made this doc while preparing for Microsoft Interview

Home    Articles    C++ Quick Refference

C++ – QUICK REFERENCE

Murugan Andezuthu Dharmaratnam

 

Object

 

Object is a single instance of a class. They are the basic runtime entities in an object-oriented system.

 

Class

 

Class is a logical method to organizing data and functions into the same structure.

. OR.

Wrapping up data and functions into a single unit.

 

·        Virtual Base Class

Duplication of common base class which uses multilevel & multiple inheritance can be avoided by making the common base class (ancestor class) as virtual base class while declaring the direct or intermediate base class as shown below.

 

 Class A

             Class B:Virtual Public A

             Class C:Virtual Public A

             Class D: Public  A, Public B

             Only One copy of the virtual base class is inherited.

                      

·        Abstract Classes

Is designed to act only as a base class. Instance of an abstract class cannot be created.

 

Data Abstraction

 

Representing essential features without including the background details or explanation.

 

Encapsulation

 

Wrapping up data and functions into a single unit. Also Known as information Hiding. Data encapsulation prevents the direct access of data, they can only be accessed though member functions.

 

 

Inheritance

 

Process by which, objects of one class acquire the properties of another class.

 

 

 

 

Polymorphism

 

It a feature where an operator or a function may exhibit different behavior depending on the type of data used in the operation.

 

            Runtime Polymorphism

·        Virtual Functions

Dynamic binding, selection of the appropriate function is done dynamically at runtime. It requires the use of pointer to objects.

                         Base Pointer, Pointing to derived object, Base pointer pointing to derived object can access 

           

            Compile Time Polymorphism

·        Operator Overloading

Return type classname::operator-()

                        {

}

Operator functions must be either member functions or friend functions.

Example Sting class Operator + overloading

           

·        Function Overloading Or Function Polymorphism

 

Dynamic Binding

 

Also known as late binding. Code associated with a given procedure call is not known until the time of call at runtime.

 

Message Passing

 

How Objects, Communicate with each other.

 

FUNCTIONS

 

Inline Functions

 

It is a function that expands inline when it is invoked. Compiler replaces with function code with the corresponding function code.

 

Friend Function

 

Consider two classes, private data of the class cannot be accesses by non-member functions.

We can define a common function to be made friendly to both the classes, which can have access to private data of both the classes.

 

·        Not in the scope of the class.

·        Can be invoked like a normal function without help of any object 

 

Class B;    // Forward Declaration

 

Class A {

     Int X;

     Friend void friendfunction(A,B);

}

 

Class B {

     Int Y;

     Void Friend friendfunction(A,B);

}

 

void friendfunction(A a1,B b1)

{

     printf(“%d %d”,a1.X,b1,Y);

}

 

Virtual Function

 

Static Member Function

 

Can have access only to other static members (Functions or Variables)

Can be called using the class name instead of the objects.

 

 

DIFFRENCES

 

Structure & Class

For Class default member of a class are private, For structure member of a class are public.

 

 

 

 





  |  HOME   |  BLOG   |  DISCUSSION FORUM   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  

Copyright 2009 @ Murugan Andezuthu Dharmaratnam