1) Which is the parameter that is added to every non-static member function when it is called?
---------------------------------------------------------------------------------------
2)
class base
{
public:
int bval;
base(){ bval=0;}
};
class deri:public base
{
public:
int dval;
deri(){ dval=1;}
};
void SomeFunc(base *arr,int size)
{
for(int i=0; i <>bval;
cout << endl; } int main() { base BaseArr[5]; SomeFunc(BaseArr,5); deri DeriArr[5]; SomeFunc(DeriArr,5); }
---------------------------------------------------------------------------------------
3)
class base { public: void baseFun(){ cout << "from base" <<>baseFun();
}
int main()
{
base baseObject;
SomeFunc(&baseObject);
Deri deriObject;
SomeFunc(&deriObject);
}
---------------------------------------------------------------------------------------
4)
class base
{
public:
virtual void baseFun(){ cout << "from base" <<>baseFun();
}
int main()
{
base baseObject;
SomeFunc(&baseObject);
Deri deriObject;
SomeFunc(&deriObject);
}
---------------------------------------------------------------------------------------
5)
class some
{
public:
~some()
{
cout << "some's destructor" << endl; } }; void main() { some s; s.~some(); } ---------------------------------------------------------------------------------------
6) #include class fig2d { int dim1; int dim2; public: fig2d() { dim1=5; dim2=6;} virtual void operator<<(ostream & rhs); }; void fig2d::operator<<(ostream &rhs) { rhs <<>dim1 <<" "<
}
*/
void main()
{
fig2d obj1;
// fig3d obj2;
obj1 << cout; // obj2 << cout; }
return true;
else
return false;
}
int main()
{
complex c1;
cout << c1;
}
Class complex
{
double re;
double im;
public:
complex() : re(0),im(0) {}
complex(double n) { re=n,im=n;};
complex(int m,int n) { re=m,im=n;}
void print() { cout << re; cout << im;}
};
void main()
{
complex c3;
double i=5;
c3 = i;
c3.print();
}
00000
2. 01010
3. from base
from base
4. from base
from Derived
5. some's destructor
some's destructor
6. 5 6
7. Runtime Error: Stack Overflow
8. Garbage value
9. 5,5
Categories
- C++ (10)
- Interview (9)
- Questions (9)
- Answers (6)
- C (5)
- constructor (5)
- VC++ (4)
- class (4)
- destructor (4)
- copy constructor (3)
- placement new (3)
- C FAQs (2)
- MFC (2)
- C++ FAQs (1)
- Memory Alignment (1)
- Mutable (1)
- Named Constructor Idiom (1)
- assignment (1)
- bit field (1)
- dangling (1)
- initialization lists (1)
- name mangling (1)
- stack unwinding (1)
- stray pointer (1)
Blog Archive
-
▼
2009
(17)
-
▼
February
(14)
- Part - 2 MFC Interview Questions & Answers
- MFC Interview Questions & Answers
- C Inteview Question
- Interview FAQs : C++ (Answers End of Post)
- Interview FAQs : C (Answers at end of post)
- C++ Interview Questions: Part 9
- C++ Interview Questions: Part 8
- C++ Interview Questions: Part 7
- C Interview Questions : Part 6
- Constructors And Destructors
- C++ Interview Questions: Part 4
- C++ Interview Questions: Part 3
- C++ Interview Questions: Part 2
- C++ Interview Questions: Part 1
-
▼
February
(14)
Most Popular Links
About Me
Wednesday, February 11, 2009
Interview FAQs : C++ (Answers End of Post)
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment