Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog

Android app on Google Play

Technical Interview Questions
Java Interview Questions
Unix Interview Questions
SQL Interview Questions
C# Interview Questions
C Interview Questions

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions

C Tutorial
C++ Tutorial

Programming Source Codes
C/C++ Source Codes
C# Source Codes

Online Quiz
C Online Quiz
C++ Online Quiz

Soft Skills
Communication Skills
Leadership Skills




Download our Android App on Google Play Now and study on the Go!

C++ Interview Questions and Answers

What is "mutable"?
"mutable" is a C++ keyword. When we declare const, none of its data members can change. When we want one of its members to change, we declare it as mutable.

A "mutable" keyword is useful when we want to force a "logical const" data member to have its value modified. A logical const can happen when we declare a data member as non-const, but we have a const member function attempting to modify that data member. For example:
class Dummy {
bool isValid() const;
mutable int size_ = 0;
mutable bool validStatus_ = FALSE;
// logical const issue resolved

bool Dummy::isValid() const
// data members become bitwise const
if (size > 10) {
validStatus_ = TRUE; // fine to assign
size = 0; // fine to assign

"mutable" keyword in C++ is used to specify that the member may be updated or modified even if it is member of constant object. Example:
class Animal {
string name;
string food;
mutable int age;
void set_age(int a);

void main() {
const Animal Tiger(’Fulffy’,'antelope’,1);
// the age can be changed since its mutable

Differences of C and C++
Could you write a small program that will compile in C but not in C++ ?

In C, if you can a const variable e.g.
const int i = 2;
you can use this variable in other module as follows
extern const int i;
C compiler will not complain.

But for C++ compiler u must write
extern const int i = 2;
else error would be generated.

Bitwise Operations - Given inputs X, Y, Z and operations | and & (meaning bitwise OR and AND, respectively), what is output equal to in?
output = (X & Y) | (X & Z) | (Y & Z);


C++ Object-Oriented Interview Questions And Answers

What is a modifier?
A modifier, also called a modifying function is a member function that changes the value of  at least one data member. In other words, an operation that modifies the state of an object. Modifiers are also known as mutators. Example: The function mod is a modifier in the following code snippet:

class test
int x,y;
x=0; y=0;
void mod()

What is an accessor?
An accessor is a class operation that does not modify the state of an object. The accessor functions need to be declared as const operations

Page Numbers :   1       2       3       4       5       6       7       8       9       10       11       12       13       14       15       16       17

Have a Question ? post your questions here. It will be answered as soon as possible.

Check Object Oriented Interview Questions for more Object Oriented Interview Questions with answers

Check Data Structure Interview Questions for more data structure interview questions with answers