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: 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: 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 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 is the difference between a copy constructor and an overloaded assignment operator?

Answer: A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class. 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: 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
Question: Why are arrays usually processed with for loop?



Answer: he real power of arrays comes from their facility of using an index variable to traverse the array, accessing each element with the same expression a[i]. All the is needed to make this work is a iterated statement in which the variable i serves as a counter, incrementing from 0 to a.length -1. That is exactly what a loop does. 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: 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: What is a conversion constructor?


Answer: A constructor that accepts one argument of a different type. Source: CoolInterview.com
Question: What?s the auto keyword good for?



Answer: Not much. It declares an object with automatic storage duration. Which means the object will be destroyed at the end of the objects scope. All variables in functions that are not declared as static and not dynamically allocated have automatic storage duration by default.

For example
int main()
{
int a; //this is the same as writing ?auto int a;?
} Source: CoolInterview.com
Question: What is the difference between class and structure?


Answer: 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. 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: What is a dangling pointer?



Answer:
A dangling pointer arises when you use
the address of an object after
its lifetime is over. This may occur
in situations like returning
addresses of the automatic variables
from a function or using the
address of the memory block after
it is freed. The following
code snippet shows this:

class Sample
{
public:
int *ptr;
Sample(int i)
{
ptr 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: 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: 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

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 Seconds