| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| why we cant create array of refrences | | 2 |
| How to change constant values? | Symphony | 4 |
| How to write a program such that it will delete itself after
exectution? | | 3 |
| What will happen if when say delete this ? | | 6 |
| Describe functional overloading? | HP | 4 |
| 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 |
| What is scope of a variable? (LOLZ) | CA | 2 |
| What is size of empty class object | CA | 4 |
| what is the size of this class
class size
{
public:
char data1;
double d;
int data2;
char data3;
double data4;
short data5;
};
please explain the padding for these double variables. | | 8 |
| write a program in c++ to generate imp
z y x w v w x y z
z y x w x y z
z y x y z
z y z
z | | 4 |
| Profiler in projects? | Symphony | 1 |
| class professor {};
class teacher : public virtual professor {};
class researcher : public virtual professor {};
class myprofessor : public teacher, public researcher {};
Referring to the sample code above, if an object of class
"myprofessor" were created, how many instances of professor
will it contain?
a) 0
b) 1
c) 2
d) 3
e) 4
| Quark | 1 |
| simple c++ program for "abcde123ba" convert "ab321edcba"
with out using string | | 3 |
| You have to take 2 arrays of length 10. Input the values of
array 1 from the user. Then copy the values of array 1 to
array 2 in ascending order
For example if user enters 9, 5, 6, 8, 1, 0, 2, 7, 4, 3
then copy the smallest element i.e. 0 first followed by 1,
2 and so
| | 1 |
| Which uses less memory?
a)
struct astruct
{
int x;
float y;
int v;
};
b)
union aunion
{
int x;
float v;
};
c)
char array[10];
| Quark | 3 |
| Can inline functions have a recursion? Give the reason? | | 2 |
| write the prime no program in c++? | | 8 |
| Difference between delete and delete[]? | TCS | 4 |
| how to find the maximum of 10 numbers ? | | 5 |
| Why for local variables the memory required to hold the
variable is allocated from the program stack and for new
its allocated from the heap? | | 1 |
| |
| For more C++ General Interview Questions Click Here |