Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

C++ Interview Questions and Answers

Test your skills through the online practice test: C++ Quiz Online Practice Test

Related differences

C vs C++Java vs C++

Ques 31. 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 Point2D{
int x; int y;

public int color;
protected bool pinned;
public Point2D() : x(0) , y(0) {} //default (no argument) constructor
public Point2D( const Point2D & ) ;
};

Point2D::Point2D( const Point2D & p )
{
this->x = p.x;
this->y = p.y;
this->color = p.color;
this->pinned = p.pinned;
}

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

Is it helpful? Add Comment View Comments
 

Ques 32. What is Boyce Codd Normal form?


A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional dependencies in F+ of the form a-> , where a and b is a subset of R, at least one of the following holds:
* a- > b is a trivial functional dependency (b is a subset of a)
* a is a superkey for schema R

Is it helpful? Add Comment View Comments
 

Ques 33. What is virtual class and 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. For instance, it may be desirable for class DatabaseCursor to have more privilege to the internals of class Database than main() has.

Is it helpful? Add Comment View Comments
 

Ques 34. What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?


virtual
 

Is it helpful? Add Comment View Comments
 

Ques 35. What do you mean by binding of data and functions?


Encapsulation.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook