April 23, 2019

Srikaanth

Check Point Software Latest C++ Interview Questions

What Are The Advantages Of Inheritance In C++?

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.

How Do You Write A Function That Can Reverse A Linked-list?

void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}  else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0; cur-> next = head;
for(; curnext !=0;)
{
cur->next  = pre;
pre  = cur;
cur  = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}

What Do You Mean By Inline Function?

The idea behind inline functions is to insert the code of a called function at the point where the function is called. If done carefully, this can improve the application's performance in exchange for increased compile time and possibly (but not always) an increase in the size of the generated binary executables.

Write A Program That Ask For User Input From 5 To 9 Then Calculate The Average?

#include  "iostream.h" intmain()
{
intMAX = 4;
int total = 0;
int average; int  numb;
for  (int i=0; KMAX; i++) {
cout«
"Please  enter your input between 5 and 9: ";
cin  » numb;
while  (numb<5 || numb>9) {
cout« "Invalid input, please re-enter: ";
cin  » numb;
}
total = total + numb;
}
average  = total/MAX;
cout« "The average number is: "
« average « "n";
 return 0;
}
Check Point Software Most Frequently Asked Latest C++ Interview Questions Answers
Check Point Software Most Frequently Asked Latest C++ Interview Questions Answers

Write A Short Code Using C++ To Print Out All Odd Number From 1 To 100 Using A For Loop

for( unsigned int i = 1; i < = 100; i++ )
if( l & 0x00000001 )
cout«i«",";

What Is Public, Protected, Private In C++?

Public, protected and private are three access specifiers in C++.
Public data members and member functions are accessible outside the class.
Protected data members and member functions are only available to derived classes.
Private data members and member functions can't be accessed outside the class. However there is an exception can be using friend classes.

Write A Function That Swaps The Values Of Two Integers, Using Int* As The Argument Type?

void swap(int* a, int*b)
{
intt;
t=*a;
*a = *b;
*b = t;
}

What Is Virtual Constructors/destructors?

Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object. There is a simple solution to this problem declare a virtual base-class destructor.

This makes all derived-class destructors virtual even though they don't have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called. Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error.

What Is The Difference Between An Array And A List?

Array:  is collection of homogeneous elements.
List :is collection of heterogeneous elements.
 Array: memory allocated is static and continuous.
 List:  memory allocated is dynamic and Random.
Array:  User need not have to keep in track of next memory allocation.
List:  User has to keep in Track of next location where memory is allocated.

Does C++ Support Multilevel And Multiple Inheritance?

Yes.

What Is A Template In C++?

Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro. Its prototype is any of the two following ones

template <class indetifier> functiondeclaration; template <typename indetifier> functiondeclaration;

The only difference between both prototypes is the use of keyword class or typename, its use is indistinct since both expressions have exactly the same meaning and behave exactly the same way.

Define A Constructor - What It Is And How It Might Be Called (2 Methods).

constructor is a member function of the class, with the name of the function being the same as the class name. It also specifies how the object should be initialized.
Ways of calling constructor

Implicitly: automatically by complier when an object is created.
Calling the constructors explicitly is possible, but it makes the code unverifiable.

You Have Two Pairs: New() And Delete() And Another Pair : Alloc() And Free(). Explain Differences Between Eg. New() And Malloc()

"new and delete" are preprocessors while "malloc() and free()" are functions, [we dont use brackets will calling new or delete].
no need of allocate the memory while using "new" but in "malloc()" we have to use "sizeof()".
"new" will initlize the new memory to 0 but "malloc()" gives random value in the new alloted memory location [better to use calloc()]

Write A Program That Will Convert An Integer Pointer To An Integer And Vice-versa.?

The following program demonstrates this.

#include<stdio.h>
#include<iosream>
#include<conio.h>
void main( )
{
    int i = 65000 ;
    int *iptr = reinterpret_cast ( i ) ;
    cout << endl << iptr ;
    iptr++ ;
    cout << endl << iptr ;
    i = reinterpret_cast ( iptr ) ;
    cout << endl << i ;
    i++ ;
    cout << endl << i ;
}

What Is Meant By Const_cast?

The const_cast is used to convert a const to a non-const. This is shown in the following program

#include
void main( )
{
     const int a = 0  ;
     int *ptr = ( int * ) &a ; //one way
     ptr = const_cast_ ( &a ) ; //better way
}
Here, the address of the const variable a is assigned to the pointer to a non-const variable. The const_cast is also used when we want to change the data members of a class inside the const member functions. The following code snippet shows this

class sample
{
    private
    int data;
    public
      void func( ) const
      {
        (const_cast (this))->data = 70 ;
      }
};

What Is The Difference Between Class And Structure In C++?

Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public. Class: Class is a successor of Structure. By default all the members inside the class are private.

What Is Rtti In C++?

Runtime type identification (RTTI) lets you find the dynamic type of an object when you have only a pointer or a reference to the base type. RTTI is the official way in standard C++ to discover the type of an object and to convert the type of a pointer or reference (that is, dynamic typing). The need came from practical experience with C++. RTTI replaces many homegrown versions with a solid, consistent approach.

What Is Encapsulation In C++?

Packaging an object's variables within its methods is called encapsulation.

Subscribe to get more Posts :