| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| 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 |
| How to construct virtual constructor | Symphony | 4 |
| string somestring ;
Which of the following choices will convert a standard C++
string object "somestring" to a C string?
a) Copy.somestring () ;
b) somestring.c_str ()
c) &somestring [1]
d) std::cstring (somestring)
e) (char *) somestring
| Quark | 1 |
| What is the difference between "calloc" and "malloc"? | ADP | 5 |
| Find the second maximum in an array?
| HCL | 2 |
| What is conversion constructor? | TCS | 1 |
| What is the difference between method and message? | HP | 2 |
| What is a "RTTI"? | HCL | 5 |
| What and all can a compiler provides by default? | HP | 3 |
| What are inline functions? | Verizon | 2 |
| How to avoid a class from instantiation? | Symphony | 5 |
| What will happen if when say delete this ? | | 3 |
| what is an array
| | 12 |
| Disadvantages of c++ | | 3 |
| When to use Multiple Inheritance? | | 4 |
| What are the different types of Storage classes? | | 3 |
| Is structure can be inherited? | HP | 3 |
| is throwing exception from a constructor not a good practice ? | Ericsson | 4 |
| What happens if an exception is throws from an object's
constructor and from object's destructor? | TCS | 2 |
| How do I open binary files? | | 1 |
| |
| For more C++ General Interview Questions Click Here |