Wednesday 11 February 2015

45 TOP C Plus Plus(C++) Interview Questions and Answers (Page 1)

1. What is C++?
Released in 1985, C++ is an object-oriented programming language created by Bjarne Stroustrup. C++ maintains almost all aspects of the C language, while simplifying memory management and adding several features - including a new datatype known as a class (you will learn more about these later) - to allow object-oriented programming. C++ maintains the features of C which allowed for low-level memory access but also gives the programmer new tools to simplify memory management.
C++ used for:
C++ is a powerful general-purpose programming language. It can be used to create small programs or large applications. It can be used to make CGI scripts or console-only DOS programs. C++ allows you to create programs to do almost anything you need to do. The creator of C++, Bjarne Stroustrup, has put together a partial list of applications written in C++.

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

3. Differentiate between a template class and class template in C++?
Template class: A generic definition or a parametrized class not instantiated until the client provides the needed information. It's jargon for plain templates. Class template: A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It's jargon for plain classes.

4. When does a name clash occur in C++?
A name clash occurs when a name is defined in more than one place. For example., two different class libraries could give two different classes the same name. If you try to use many class libraries at the same time, there is a fair chance that you will be unable to compile or link the program because of name clashes.

5. Define namespace in C++?
It is a feature in C++ to minimize name collisions in the global name space. This namespace keyword assigns a distinct name to a library that allows other libraries to use the same identifier names without creating any name collisions. Furthermore, the compiler uses the namespace signature for differentiating the definitions.

6. What is the use of 'using' declaration in C++?
A using declaration in C++ makes it possible to use a name from a namespace without the scope operator.

7. Differentiate between the message and method in C++?
Message in C++ :
* Objects communicate by sending messages to each other.
* A message is sent to invoke a method in C++.
Method in C++ :
* Provides response to a message.
* It is an implementation of an operation in C++.

8. What is an adaptor class or Wrapper class in C++?
A class that has no functionality of its own is an Adaptor class in C++. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non-object-oriented implementation.

9. What is a Null object in C++?
It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.

10. What is class invariant in C++?
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.
More Questions & Answers :-

1 comment:

  1. Hola,


    Great post. Well though out. This piece reminds me when I was starting out #topic after graduating from college.

    I am working LDPC encoding and decoding for mini project work. With my effort i have completed LDPC encoding but struggling with LDPC decoding. I need to complete this project within short period so please help me.

    I don`t know how to start decoding algorithm in C language but i do have algorithm. So, can anyone help me in writing C language for decoding procedure.

    Thank you very much and will look for more postings from you.


    Thank you,

    ReplyDelete