Important: Use custom search function to get better results from our thousands of pages

Use " " for compulsory search eg:"electronics seminar" , use -" " for filter something eg: "electronics seminar" -"/tag/" (used for exclude results from tag pages)

Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ Interview Questions
Post: #1

C++ Interview Questions

.pdf  C++ Interview.pdf (Size: 61.52 KB / Downloads: 137)

1. 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.

2. What do you mean by pure virtual functions?

A pure virtual member function is a member function that the base class forces derived classes to
provide. Normally these member functions have no implementation. Pure virtual functions are
equated to zero.

3.What is namespace?

Namespaces allow us to group a set of global classes, objects and/or functions under a name. To say
it somehow, they serve to split the global scope in sub-scopes known
as namespaces.

4. What is RTTI?

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.

5. What is a template?

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.

6. 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.

7. What is virtual class and friend class?

Friend classes are used when two or more classes are designed to work together and need access
to each other's implementation in ways that the rest of the world
shouldn't be allowed to have. In other words, they help keep private things private. For instance, it
may be desirable for class DatabaseCursor to have more privilege to the internals of class Database
than main() has.

8. Difference between realloc() and free()?

The free subroutine frees a block of memory previously allocated by the malloc subroutine.
Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a
null value, no action will occur. The realloc subroutine changes the size of the block of memory
pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and
returns a new pointer to the block. The pointer specified by the Pointer parameter must have been
created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or
realloc subroutines. Undefined results occur if the Pointer parameter is not a valid pointer.
Post: #2
What are the differences between C and C ++?
1) C ++ is a superset type of C, most C programs except few exceptions (see this and this) work in C ++ as well.
2) C is a procedural programming language, but C ++ supports both procedural programming and object programming.
3) Since C ++ supports object-oriented programming, it supports functions such as overloading functions, templates, inheritance, virtual functions, friend functions. These characteristics are absent in C.
4) C ++ supports exception handling at the language level, while handling C exceptions is done in the traditional if-else style.
5) C ++ supports references, C does not.
6) In C, scanf () and printf () are mainly used as input / output. C ++ mainly uses flows to perform input and output operations. cin is standard input flow and cout is standard output flow.
There are many more differences, above is a list of major differences.
What are the differences between references and pointers?
Both references and pointers can be used to change the local variables of a function within another function. Both can also be used to save copies of large objects when passed as arguments to functions or returned from functions for efficiency gains.
Despite the previous similarities, there are the following differences between references and pointers.
References are less powerful than pointers
1) Once a reference is created, you can not refer to another object later; It can not be reseated. This is often done with pointers.
2) References can not be NULL. Pointers are often made NULL to indicate that they are not pointing at anything valid.
3) A reference must be initialized when it is declared. There is no such restriction with pointers
Because of the above limitations, references in C ++ can not be used to implement data structures such as Linked List, Tree, etc. In Java, references have no previous constraints and can be used to implement all data structures. References being more powerful in Java, is the main reason why Java does not need pointers.
References are safer and easier to use:
1) Safer: Since references need to be initialized, wild references like wild pointers are unlikely to exist. It is still possible to have references that do not refer to a valid place (see questions 5 and 6 in the following exercise)
2) Easier to use: References do not need dereferencing operator to access the value. They can be used as normal variables. The '&' operator is only needed at the time of the declaration. You can also access members of an object reference with the dot operator ('.'), Unlike pointers where the arrow operator (->) is required to access members.

Marked Categories : c interview questions with answers pdf, c interview questions and answers pdf, latest c interview question point of view pdf, c questions for interviews, c and c one word interview questions with answers, question and answers in c, c interview questions, pdf virtual base class in c, c interview questions and answers on pointers and objects pdf,

Quick Reply
Type your reply to this message here.

Image Verification
Image Verification
(case insensitive)
Please enter the text within the image on the left in to the text box below. This process is used to prevent automated posts.

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  viva questions on the project determination of contents of soft drinks in chemistry Guest 1 0 01-02-2018 10:55 AM
Last Post: dhanabhagya
  viva questions on the project determination of contents of soft drinks in chemistry Guest 1 0 27-01-2018 11:20 AM
Last Post: dhanabhagya
  viva questions on the project determination of contents of soft drinks in chemistry Guest 1 0 27-01-2018 11:10 AM
Last Post: dhanabhagya
  servlet jsp multiple choice questions and answers pdf Guest 3 2,866 18-01-2018 02:42 PM
Last Post: dhanabhagya
  cdot apprentice trainee interview question and answer for electronics Guest 1 367 17-11-2017 01:42 PM
Last Post: jaseela123
  word hunt questions in computer Guest 1 322 17-11-2017 12:09 PM
Last Post: jaseela123
  an interview with a share broker project in wikipedia Guest 1 0 15-11-2017 11:10 AM
Last Post: jaseela123
  an interview with share broker question 12th project Guest 1 0 15-11-2017 11:10 AM
Last Post: jaseela123
Heart newton ring experiment viva questions wit answers Guest 1 369 12-10-2017 12:54 PM
Last Post: jaseela123
  electrical circuits lab viva questions and answers Guest 1 147 12-10-2017 10:18 AM
Last Post: jaseela123
This Page May Contain What is C++ Interview Questions And Latest Information/News About C++ Interview Questions,If Not ...Use Search to get more info about C++ Interview Questions Or Ask Here