| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| int f() {
int I = 12;
int &r = I;
r += r / 4;
int *p = &r;
*p += r;
return I;
}
Referring to the sample code above, what is the return value
of the function "f()"?
a) 12
b) 15
c) 24
d) 17
e) 30
| Quark | 2 |
| Why preincrement operator is faster than postincrement? | | 3 |
| Write the program for fibonacci in c++? | | 3 |
| What is Virtual Inheritance? | Wipro | 2 |
| How can you quickly find the number of elements stored in a
a) static array b) dynamic array ? | Lucent | 3 |
| class Foo {
public:
Foo(int i) { }
};
class Bar : virtual Foo {
public:
Bar() { }
};
Bar b;
Referring to the above code, when the object 'b' is defined,
a compiler error will occur. What action fixes the compiler
error?
a) Adding a virtual destructor to the class Bar
b) Adding a constructor to Bar which takes an int parameter
c) Adding "Foo()" to the Bar constructor
d) Adding a copy constructor to the class Foo
e) Adding "Foo(0)" to the Bar::Bar initializer list
| Quark | 1 |
| Implement strcmp | Citadel | 2 |
| write the prime no program in c++? | | 4 |
| What is problem with Runtime type identification?
| | 1 |
| class X
{
public:
int x;
static void f(int z);
};
void X::f(int y) {x=y;}
What is the error in the sample code above?
a) The class X does not have any protected members.
b) The static member function f() accesses the non-static z.
c) The static member function f() accesses the non-static x.
d) The member function f() must return a value.
e) The class X does not have any private members.
| Quark | 1 |
| implement stack using stack.h headerfile functions | Subex | 1 |
| How long does this loop run:
for(int x=0; x=3; x++)
a) Never
b) Three times
c) Forever
| Quark | 9 |
| Which of the Standard C++ casts can be used to perform a
?safe? downcast:
a) reinterpret_cast
b) dynamic_cast
c) static_cast
d) const_cast
| Quark | 1 |
| 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 |
| Consider a c++ template funtion
template<class T>
T& Add(T a, T b){return a+b ;}
if this function is called as
T c = Add("SAM", "SUNG");
what will happen? What is the problem in the template
declaration/ How to solve the problem. | Samsung | 4 |
| Difference between Overloading and Overriding? | HP | 4 |
| Disadvantages of c++ | | 3 |
| How do you know that your class needs a virtual destructor? | Lucent | 3 |
| What is a pure virtual function?
Why is it represented as = 0...how is the internal
implementation for the same | CTS | 3 |
| class basex
{
int x;
public:
void setx(int y) {x=y;}
};
class derived : basex {};
What is the access level for the member function "setx" in
the class "derived" above?
a) private
b) local
c) global
d) public
e) protected
| Quark | 1 |
| |
| For more C++ General Interview Questions Click Here |