When is a template a better solution than a base class?
C++ Interview Questions and Answers
(Continued from previous question...)
When is a template a better solution than a base class?
When you are designing a generic class to contain or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the genericity) to the designer of the container or manager class.
(Continued on next question...)
Other Interview Questions
- What is C++?
- What is a modifier?
- What is an accessor?
- Differentiate between a template class and class template.
- When does a name clash occur?
- Define namespace.
- What is the use of ‘using’ declaration.
- What is an Iterator class?
- What is an incomplete type?
- What is a dangling pointer?
- Differentiate between the message and method.
- What is an adaptor class or Wrapper class?
- What is a Null object?
- What is class invariant?
- What do you mean by Stack unwinding?
- Define precondition and post-condition to a member function.
- What are the conditions that have to be met for a condition to be an invariant of the class?
- What are proxy objects?
- Name some pure object oriented languages.
- What is a node class?
- What is an orthogonal base class?
- What is a container class? What are the types of container classes?
- How do you write a function that can reverse a linked-list?
- What is polymorphism?
- How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
- How can you tell what shell you are running on UNIX system?
- What is Boyce Codd Normal form?
- What is pure virtual function?
- Write a Struct Time where integer m, h, s are its members
- How do you traverse a Btree in Backward in-order?
- What is the two main roles of Operating System?
- In the derived class, which data member of the base class are visible?
- How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
- What is the difference between realloc() and free()?
- What is function overloading and operator overloading?
- What is the difference between declaration and definition?
- What are the advantages of inheritance?
- How do you write a function that can reverse a linked-list?
- What do you mean by inline function?
- Write a program that ask for user input from 5 to 9 then calculate the average
- Write a short code using C++ to print out all odd number from 1 to 100 using a for loop
- What is public, protected, private?
- Write a function that swaps the values of two integers, using int* as the argument type.
- Tell how to check whether a linked list is circular.
- What is polymorphism?
- What is virtual constructors/destructors?
- What is the difference between an ARRAY and a LIST?
- Does c++ support multilevel and multiple inheritance?
- What is a template?
- Define a constructor - What it is and how it might be called (2 methods).
- You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. new() and malloc()
- What is the difference between class and structure?
- What is RTTI?
- What is encapsulation?
- Explain term POLIMORPHISM and give an example using eg. SHAPE object: If I have a base class SHAPE, how would I define DRAW methods for two objects CIRCLE and SQUARE
- What is an object?
- How can you tell what shell you are running on UNIX system?
- Describe PRIVATE, PROTECTED and PUBLIC – the differences and give examples.
- What is namespace?
- What do you mean by inheritance?
- What is a COPY CONSTRUCTOR and when is it called?
- What is Boyce Codd Normal form?
- What is virtual class and friend class?
- What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?
- What do you mean by binding of data and functions?
- What are 2 ways of exporting a function from a DLL?
- What is the difference between an object and a class?
- Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].
- What is a class?
- What is friend function?
- Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?
- What is abstraction?
- What are virtual functions?
- What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator.
- What is a scope resolution operator?
- What do you mean by pure virtual functions?
- What is polymorphism? Explain with an example?
- How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array? How can you find the nodes with repetetive data in a linked list?
- What’s the output of the following program? Why?
- Why are arrays usually processed with for loop?
- What is an HTML tag?
- Explain which of the following declarations will compile and what will be constant ...
- You’re given a simple code for the class BankCustomer. Write the following functions ...
- What problems might the following macro bring to the application?
- Anything wrong with this code? T *p = new T[10]; delete p;
- Anything wrong with this code? T *p = 0; delete p;
- How do you decide which integer type to use?
- What’s the best way to declare and define global variables?
- What does extern mean in a function declaration?
- What can I safely assume about the initial values of variables which are not explicitly initialized?
- What is the difference between char a[] = “string”; and char *p = “string”;?
- What’s the auto keyword good for?
- What is the difference between char a[] = “string”; and char *p = “string”; ?
- How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
- What does extern mean in a function declaration?
- How do I initialize a pointer to a function?
- How do you link a C++ program to C functions?
- Explain the scope resolution operator.
- What are the differences between a C++ struct and C++ class?
- How many ways are there to initialize an int with a constant?
- I write a program in C++ that asks the user for names of students and their cooresponding midterm scores ...
- How does throwing and catching exceptions differ from using setjmp and longjmp?
- What is a default constructor?
- What is a conversion constructor?
- What is the difference between a copy constructor and an overloaded assignment operator?
- When should you use multiple inheritance?
- Explain the ISA and HASA class relationships. How would you implement each in a class design?
- When is a template a better solution than a base class?
- What is a mutable member?
- What is an explicit constructor?
- What is the Standard Template Library (STL)?
- Describe run-time type identification.
- What problem does the namespace feature solve?
- Are there any new intrinsic (built-in) data types?
- Will the following program execute?
- Will it execute or not?
- What is the difference between Mutex and Binary semaphore?
- In C++, what is the difference between method overloading and method overriding?
- What methods can be overridden in Java?
- What are the defining traits of an object-oriented language?
- Write a program that ask for user input from 5 to 9 then calculate the average
- Can you be bale to identify between Straight- through and Cross- over cable wiring? and in what case do you use Straight- through and Cross-over?
- If you hear the CPU fan is running and the monitor power is still on, but you did not see any thing show up in the monitor screen. What would you do to find out what is going wrong?
- Assignment Operator - What is the diffrence between a "assignment operator" and a "copy constructor"?
- "mutable" Keyword - What is "mutable"?
- RTTI - What is RTTI?
- STL Containers - What are the types of STL containers?
- Virtual Destructor - What is the need for “Virtual Destructor”?
- Differences of C and C++ Could you write a small program that will compile in “C” but not in “C++”?
- What is output equal to in Bitwise Operations - ...
|