| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| What is the Difference between "printf" and "sprintf"? | iSoft | 3 |
| 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 |
| Can we have "Virtual Constructors"? | TCS | 5 |
| what is static function | Patni | 2 |
| What is the Difference between "vector" and "array"? | TCS | 6 |
| What is conversion constructor? | TCS | 1 |
| What is the Diffrence between a "assignment operator" and a
"copy constructor"? | Wipro | 2 |
| Please post the model question paper of hal? | | 1 |
| Write any small program that will compile in "C" but not in
"C++"? | | 3 |
| What are the different types of polymorphism? | | 2 |
| 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 |
| 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 |
| How do you link a C++ program to C functions?
| | 2 |
| How to implement flags? | Symphony | 1 |
| What are the differences between public, private, and
protected access? | Wipro | 4 |
| 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 |
| How to avoid a class from instantiation? | Symphony | 5 |
| If P is the population on the first day of the year, B is
the birth rate, and D is the death rate, the estimated
population at the end of the year is given by the formula:
The population growth rate is given by the formula:
B – D
Write a program that prompts the user to enter the starting
population, birth and death rates, and n, the number of
years. The program should then calculate and print the
estimated population after n years. Your program must have
at least the following functions:
1. growthRate: This function takes its parameters the
birth and death rates, and it returns the population growth
rate.
2. estimatedPopulation: This function takes its
parameters the current population, population growth rate,
and n, the number of years. It returns the estimated
population after n years
Your program should not accept a negative birth rate,
negative death rate, or a population less than 2.
| | 1 |
| Difference between Top down and bottom up approaches for a
given project ? | HP | 1 |
| In C++ cout is:
a) object
b) class
c) something else | Lehman-Brothers | 10 |
| |
| For more C++ General Interview Questions Click Here |