CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies
C++ Interview Questions & Answers - Learning Mode
COOLINTERVIEW.COM PROGRAMMING LANGUAGES INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS QUESTIONS & ANSWERS - LEARNING MODE

C++ Interview Questions & Answers - Learning Mode

C++ is an object oriented programming (OOP) language, developed by Bjarne Stroustrup, and is an extension of C language. It is therefore possible to code C++ in a "C style" or "object-oriented style." It has imperative, object-oriented and generic programming features, while also providing facilities for low-level memory manipulation. It was designed with a bias toward system programming and embedded, resource-constrained and large systems, with performance, efficiency and flexibility of use as its design highlights.

Try C++ Interview Questions & Answers - Exam Mode
Subcategories for C++ Interview Questions & Answers - Learning Mode

Following are sub categories for which Interview Questions & Answers are available under C++ Interview Questions & Answers - Learning Mode. Please select the appropriate sub-category:-

Arrays, Strings, Pointers and References in C++ Interview Questions & Answers (48) Learning Mode | Exam Mode

C++ Basics Interview Questions & Answers (66) Learning Mode | Exam Mode

Control Flow in C++ Interview Questions & Answers (3) Learning Mode | Exam Mode

Exceptions in C++ Interview Questions & Answers (5) Learning Mode | Exam Mode

Functions in C++ Interview Questions & Answers (27) Learning Mode | Exam Mode

Inheritance in C++ Interview Questions & Answers (30) Learning Mode | Exam Mode

Input and Output Operations in C++ Interview Questions & Answers (12) Learning Mode | Exam Mode

Object Oriented Programming in C++ Interview Questions & Answers (42) Learning Mode | Exam Mode

Operator Overloading in C++ Interview Questions & Answers (18) Learning Mode | Exam Mode

Operators in C++ Interview Questions & Answers (24) Learning Mode | Exam Mode

Templates in C++ Interview Questions & Answers (12) Learning Mode | Exam Mode

Variables in C++ Interview Questions & Answers (13) Learning Mode | Exam Mode

Virtual Functions in C++ Interview Questions & Answers (26) Learning Mode | Exam Mode

1 2 3 4 5 6 7 8 9 10 11 12 Next

Sort By : Latest First | Oldest First | By Rating

C++ Interview Questions & Answers - Learning Mode
Try C++ Interview Questions & Answers - Exam Mode
Question: What are the advantages of using cin and cout compared to scanf(...) and printf(...), respectively?

Answer: Compared to the standard C functions printf() and scanf(), the usage of the cin and cout is more type safe.
The format strings, which are used with printf() and scanf() can define wrong format specifies for their arguments, for which the compiler does not warn.
In contrast, argument checking with c in and cout is performed by the compiler.
C in and Cout are stream classes that could be used to receive and print objects respectively. Source: CoolInterview.com
Question: What are the main underlying concepts of object orientation?

Answer:
Objects, messages, class, inheritance and polymorphism are the main concepts of object orientation.
Source: CoolInterview.com
Question: How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?



Answer: If you want the code to be even slightly readable, you will use typedefs.
typedef char* (*functiontype_one)(void);
typedef functiontype_one (*functiontype_two)(void);
functiontype_two myarray[N]; //assuming N is a const integral Source: CoolInterview.com
Question: What do you mean by Stack unwinding?


Answer:
It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught. Source: CoolInterview.com
Question: What are the advantages of operator overloading?

Answer: Operator overloading is used to provide some extra features, behaviors and abilities to the users of a particular class. This feature in C++ helps in controlling the functions performed by an operator and reduces the chance of occurrence of errors in a program. Source: CoolInterview.com
Question: What is polymorphism?


Answer: Polymorphism is the idea that a base class can be inherited by several classes. A base class pointer can point to its child class and a base class array can store different child class objects. Source: CoolInterview.com
Question: You?re given a simple code for the class BankCustomer. Write the following functions ...

You?re given a simple code for the class BankCustomer. Write the following functions:
* Copy constructor
* = operator overload
* == operator overload
* + operator overload (customers? balances should be added up, as an example of joint account between husband and wife)



Answer:
Note:Anyone confusing assignment and equality operators should be dismissed from the interview. The applicant might make a mistake of passing by value, not by reference. The candidate might also want to return a pointer, not a new object, from the addition operator. Slightly hint that you?d like the value to be changed outside the function, too, in the first case. Ask him whether the statement customer3 = customer1 + customer2 would work in the second case. Source: CoolInterview.com
Question: Write a fucntion that will reverse a string.


Answer: char *strrev(char *s)
{
int i = 0, len = strlen(s);
char *str;
if ((str = (char *)malloc(len+1)) == NULL)
/*cannot allocate memory */
err_num = 2;
return (str);
}
while(len)
str[i++]=s[?len];
str[i] = NULL;
return (str);
} Source: CoolInterview.com
Question: What is class invariant?


Answer:
A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, and they must be preserved under all operations of the class. In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class.
Source: CoolInterview.com
Question: What is difference between template and macro ?

Answer: A template can be used to create a family of classes or function.A template describes a set of related classes or set of related functions in which a list of parameters in the declaration describe how the members of the set vary.
Identifiers that represent statements or expressions are called macros. Source: CoolInterview.com
Question: How do you link a C++ program to C functions?


Answer: By using the extern "C" linkage specification around the C function declarations. Source: CoolInterview.com
Question: What is a concrete class?

Answer:
A concrete class is used to define a useful object that can be instantiated as an automatic variable on the program stack. The implementation of aconcrete class is defined. The concrete class is not intended to be a base class and no attempt to minimize dependency on other classes in the implementation or behavior of the class. Source: CoolInterview.com
Question: What is the difference between declaration and definition?


Answer:
The declaration tells the compiler that at some later point we plan to present the definition of this declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.: void stars () // declarator
{
for(int j=10; j > =0; j--) //function body
cout << *;
cout << endl; } Source: CoolInterview.com
Question: Describe Stacks and name a couple of places where stacks are useful.


Answer:
A Stack is a linear structure in which insertions and deletions are always made at one end, called the top. This updating policy is called last in, first out (LIFO). It is useful when we need to check some syntex errors, such as missing parentheses. Source: CoolInterview.com
Question: What are the conditions that have to be met for a condition to be an invariant of the class?


Answer: * The condition should hold at the end of every constructor.
* The condition should hold at the end of every mutator (non-const) operation. Source: CoolInterview.com
Question: Define precondition and post-condition to a member function.

Answer:

Precondition: A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold. For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation. Post-condition: A post-condition is a condition tha Source: CoolInterview.com
Question: What is polymorphism?


Answer:
Polymorphism is the idea that a base class can be inherited by several classes. A base class pointer can point to its child class and a base class array can store different child class objects. Source: CoolInterview.com
Question: What are the defining traits of an object-oriented language?


Answer:
The defining traits of an object-oriented langauge are:
* encapsulation
* inheritance
* polymorphism Source: CoolInterview.com
Question: Can I define a type that is an alias of another type (like typedef in C++)?

Answer: Not exactly. You can create an alias within a single file with the "using" directive: using System; using Integer = System.Int32; // alias
But you can't create a true alias, one that extends beyond the file in which it is declared. Refer to the C# spec for more info on the 'using' statement's scope. Source: CoolInterview.com
Question: STL Containers - What are the types of STL containers?

Answer:

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 Source: CoolInterview.com

1 2 3 4 5 6 7 8 9 10 11 12 Next



India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.46875 Seconds