| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| What are the basics of classifying different storage types,
why? | Symphony | 1 |
| is throwing exception from a constructor not a good practice ? | Ericsson | 4 |
| How many lines of code you have written for a single program? | BoA | 1 |
| Shall we use 'free' to free memory assigned by new, What are
the further consequences?? | Symphony | 4 |
| Why do C++ compilers need name mangling? | Lucent | 1 |
| Can you explain the term "resource acquisition is
initialization?" | | 1 |
| What is the difference between "overloading" and "overridding"? | | 3 |
| Evaluate:
int fn(int v)
{
if(v==1 || v==0)
return 1;
if(v%2==0)
return fn(v/2)+2;
else
return fn(v-1)+3;
}
for fn(7);
a) 10
b) 11
c) 1
| Quark | 1 |
| how to swap two numbers with out using temp variable | | 6 |
| class Alpha {
public:
char data[10000];
Alpha();
~Alpha();
};
class Beta {
public:
Beta() { n = 0; }
void FillData(Alpha a);
private:
int n;
};
How do you make the above sample code more efficient?
a) If possible, make the constructor for Beta private to
reduce the overhead of public constructors.
b) Change the return type in FillData to int to negate the
implicit return conversion from "int" to "void".
c) Make the destructor for Alpha virtual.
d) Make the constructor for Alpha virtual.
e) Pass a const reference to Alpha in FillData
| Quark | 1 |
| Do we have private destructors? | Symphony | 9 |
| What is the difference between public, private, protected
inheritance? | Wipro | 4 |
| How to avoid changing constant values? | Symphony | 1 |
| what is difference between static and non-static variables | | 4 |
| Explain the ISA and HASA class relationships. How would you
implement each in a class design? | | 2 |
| In a class, there is a reference or pointer of an object of
another class embedded, and the memory is either allocated
or assigned to the new object created for this class. In
the constructor, parameters are passed to initialize the
data members and the embedded object reference to get
inialized. What measures or design change should be advised
for proper destruction and avioding memory leaks, getting
pointers dangling for the embedded object memory
allocation? Please suggest. | GE | 3 |
| What is the difference between = and == in C? | Intel | 8 |
| How the V-Table mechanism works? | HP | 3 |
| What are the differences between a struct and a class in
C++? | Wipro | 4 |
| what is static function | Patni | 2 |
| |
| For more C++ General Interview Questions Click Here |