GeeksforGeeks

Add Interview/written questions to Interview Corner!!
Register  |  Login

Browsing the topic GFacts

In C++, delete operator should only be used either for the pointers pointing to the memory allocated using new operator or for a NULL pointer, and free() should only be used either for the pointers pointing to the memory allocated using malloc() or for a NULL pointer.

Read More »

In C++, a static member function of a class cannot be virtual. For example, below program gives compilation error.

Read More »

Enumeration constants (enum values) are always of type int in C, whereas they are distinct types in C++ and may have size different from that of int.

Read More »

Calling an undeclared function is poor style in C and illegal in C++. So is passing arguments to a function using a declaration that doesn’t list argument types:

Read More »

In C++, compiler by default creates default constructor for every class. But, if we define our own parametrized constructor, then compiler doesn’t create the default constructor and default constructor may not exist in the class.

Read More »

In C++, Reference variables are safer than pointers because reference variables must be initialized and they cannot be changed to refer to something else once they are initialized. But there are exceptions where we can have invalid references.

Read More »

In C, we cannot access a global variable if we have a local variable with same name, but it is possible in C++ using scope resolution operator (::).

Read More »

The number of structurally different Binary Trees with n nodes is Catalan number Cn = (2n)!/(n+1)!*n!

Read More »

Don’t write a copy constructor if shallow copies are ok: In C++, If an object has no pointers to dynamically allocated memory, a shallow copy is probably sufficient. Therefore the default copy constructor, default assignment operator, and default destructor are ok and you don’t need to write your own.
Source: http://www.fredosaurus.com/notes-cpp/oop-condestructors/copyconstructors.html

Read More »

In C, it might not be possible to have function names on left side of an expression, but it’s possible in C++.

Read More »

In C, it is never safe to depend on the order of evaluation of side effects. For example, a function call like below may very well behave differently from one compiler to another:

Read More »

In C, data type of character constants is int, but in C++, data type of same is char.

Read More »

Total number of possible Binary Search Trees with n nodes = Catalan number Cn = (2n)!/(n+1)!*n!

Read More »

To uniquely construct a Binary Tree, Inorder together with either Postorder or Preorder must be given (See this for details). However, either Postorder or Preorder traversal is sufficient to uniquely construct a Binary Search Tree.

Read More »

In C, variables are always statically (or lexically) scoped i.e., binding of a variable can be determined by program text and is independent of the run-time function call stack.

Read More »

“Pointer arithmetic and array indexing [that] are equivalent in C, pointers and arrays are different” – Wayne Throop
References:
http://c-faq.com/aryptr/aryptrequiv.html

Read More »

In C++, following operators can not be overloaded:
. (Member Access or Dot operator)
?: (Ternary or Conditional Operator )

Read More »

In C++, a Copy Constructor may be called in following cases:

Read More »

C allows a void* pointer to be assigned to any pointer type without a cast, whereas C++ does not; this idiom appears often in C code using malloc memory allocation. For example, the following is valid in C but not C++:

Read More »

In C, return type of getchar(), fgetc() and getc() is int (not char). So it is recommended to assign the returned values of these functions to an integer type variable.

Read More »