| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| What are the different types of polymorphism? | | 2 |
| What is the difference between operator new and the new
operator? | Wipro | 1 |
| How to construct virtual constructor | Symphony | 4 |
| What are the types of STL containers? | | 1 |
| 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 "strstream" ? | Huawei | 1 |
| What is the difference between public, private, protected
inheritance? | Wipro | 4 |
| The "virtual" specifier in a member function enables which
one of the following?
a) Monmorphism
b) Late binding
c) Metamorphism
d) Solomorphism
e) Inheritance
| Quark | 3 |
| Can we have "Virtual Constructors"? | TCS | 5 |
| Explain the need for "Virtual Destructor"? | Infosys | 1 |
| What and all can a compiler provides by default? | HP | 3 |
| Can we use resume in error handling i.e. in the catch block | Infosys | 3 |
| How do you know that your class needs a virtual destructor? | Lucent | 3 |
| How would you stop a class from class from being derived or
inherited?The constructer should not be Private,as object
instantiation should be allowed. | | 14 |
| Find out the bug in this code,because of that this code
will not compile.......
#include <iostream>
#include <new>
#include <cstring>
using namespace std;
class balance {
double cur_bal;
char name[80];
public:
balance(double n, char *s) {
cur_bal = n;
strcpy(name, s);
}
~balance() {
cout << "Destructing ";
cout << name << "\n";
}
void set(double n, char *s) {
cur_bal = n;
strcpy(name, s);
}
void get_bal(double &n, char *s) {
n = cur_bal;
strcpy(s, name);
}
};
int main()
{
balance *p;
char s[80];
double n;
int i;
try {
p = new balance [3]; // allocate entire array
} catch (bad_alloc xa) {
cout << "Allocation Failure\n";
return 1;
} | Impetus | 2 |
| How is an Abstract Base Class(ABC) related to an "Abstract
Data Type" (ADT) | | 2 |
| class Foo {
const int x;
protected:
Foo(int f);
~Foo();
};
Foo f;
Referring to the sample code above, why will the class
declaration not compile?
a) The variable x is const.
b) The destructor is protected.
c) The destructor is not public.
d) The constructor is protected.
e) There is no default constructor.
| Quark | 4 |
|
1. What does the following do:
void afunction(int *x)
{
x=new int;
*x=12;
}
int main()
{
int v=10;
afunction(&v);
cout<<v;
}
a) Outputs 12
b) Outputs 10
c) Outputs the address of v
| Quark | 3 |
| What is size of null class? | HP | 3 |
| what is static function | Patni | 2 |
| |
| For more C++ General Interview Questions Click Here |