Thursday 16 March 2017

C++

What are the advantages of inheritance?
• It permits code reusability.
• Reusability saves time in program development.
• It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional.


What is a COPY CONSTRUCTOR and when is it called?
A copy constructor is a method that accepts an object of the same class and copies it’s data members to the object on the left part of assignement:

class cs{

public int color;
public Cs() : color(0) } //default (no argument) constructor
public Cs( const Point2D & ) ;
};

Cs::Cs( const Cs & p )
{
this->color = p.color;
}

main(){
Cs  MyPoint;
Cs.color = 345;
Cs AnotherPoint = Cs( MyPoint ); // now AnotherPoint has color = 345

}

What is friend class?
Friend classes are used when two or more classes are designed to work together and need access to each other's implementation in ways that the rest of the world shouldn't be allowed to have. In other words, they help keep private things private.


Virtual Function: A virtual function is a function in a base class that is declared using the keyword virtual.
Pure Virtual Functions: It's possible that you'd want to include a virtual function in a base class so that it may be redefined in a derived class to suit the objects of that class,.

STL Containers - What are the types of STL containers?
There are 3 types of STL containers:

1. Adaptive containers like queue, stack
2. Associative containers like set, map
3. Sequence containers like vector, deque


What is the use of ‘using’ declaration. ?
A using declaration makes it possible to use a name from a namespace without the scope operator.

 
 
 

 
 

No comments:

Post a Comment