October 31, 2018

Sreekanth B

SYNNEX Most Frequently Asked C++ Interview Questions Answers

What Is Friend Function In C++?

As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be listed in the class definition.

What Is A C++ Class?

Class is a user-defined data type in C++. It can be created to solve a particular kind of problem. After creation the user need not know the specifics of the working of a class.

Suppose That Data Is An Array Of 1000 Integers. Write A Single Function Call That Will Sort The 100 Elements Data [222] Through Data [321]?

quicksort((data + 222),100);

What Is The Difference Between An Object And A Class?

Classes and objects are separate but related concepts. Every object belongs to a class and every class contains one or more related objects.

A Class is static. All of the attributes of a class are fixed before, during, and after the execution of a program. The attributes of a class don't change.
The class to which an object belongs is also (usually) static. If a particular object belongs to a certain class at the time that it is created then it almost certainly will still belong to that class right up until the time that it is destroyed.
 An Object on the other hand has a limited lifespan. Objects are created and eventually destroyed. Also during that lifetime, the attributes of the object may undergo significant change.
SYNNEX Most Frequently Asked C++ Interview Questions Answers
SYNNEX Most Frequently Asked C++ Interview Questions Answers

What Are 2 Ways Of Exporting A Function From A Dll?

1 .Taking a reference to the function from the DLL instance.
2. Using the DLL 's Type Library.

What Do You Mean By Binding Of Data And Functions?

Encapsulation.

What Is The Word You Will Use When Defining A Function In Base Class To Allow This Function To Be A Polimorphic Function?

virtual.

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.

What Is Boyce Codd Normal Form In C++?

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.

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

What Do You Mean By Inheritance?

Inheritance is the process of creating new classes, called derived classes, from existing classes or base classes. The derived class inherits all the capabilities of the base class, but can add embellishments and refinements of its own.

Can We Define A Constructor As Virtual In C++?

No, we cannot define constructors as virtual because constructors have the same name as their classes and no two constructors of base-derived classes can have the same name. So, when we initialize an object of the base or derived class with the help of virtual constructors, the base constructor is invoked instead of the derived constructor. Therefore, it is not possible to define a constructor as virtual.

Can We Declare A Base-class Destructor As Virtual?

Yes, we can declare a base-class destructor as virtual that makes all derived-class destructors as virtual even if they do not have the same name as base-destructor. The problem arises when the derived class's pointer refers to a base class. For this reason, the base class destructor should be declared as virtual so that the appropriate destructor is called on calling the delete method of the base class object.

How Does A Copy Constructor Differs From An Overloaded Assignment Operator?

A copy constructor uses the value of an argument to construct a new object. We can use an overload assignment operator to assign the value of an existing object of the same class to another existing object in that class.

Subscribe to get more Posts :