Technical Interview

Home
Added Recently
Data Structures
Puzzles
Google & Microsoft
C/C++ Questions
Java Interview Questions
Quantitative Problems
Algorithms
Featured Articles
Amazon Interview Question
Compaq Interview Question
Technical Interview
Interview Process
Introduction Questions
Object Oriented
Google Pages
Fundamental Questions
Resume Tips
Links
Contact Us
Submit Question/Answer

What is wrong with this piece of code?

class Foo
{
public:
virtual Foo() {...}
...
}
 

Solution


 

Given this code structure, what appears on the console:

void goodbye(const char* clsid)
{
std::cout << "Good-bye, " << clsid << "!" << std::endl;
}

class Foo
{
public:
~Foo() { goodbye("Foo"); }
};

class Bar : public Foo
{
public:
~Bar() { goodbye("Bar"); }
};

int main(int argc, char* argv[])
{
Foo* p = new Bar;
delete p;
return 0;
}

 

Solution

 

1. Why we can not declare constructor to virtual?
2. Why we can declare destructor to virtual?
3. what is difference between function overloading and overriding?
4. where the Volatile variable are stored in memory? 

Solution




Is it possible with C++ to have my variables stored in a file , then at run time I initialize variables with those names,ex : in a file I will have a variable called book and besides it for example its value 5 "book 5"
then in the program I read this record and initialize the variable , also is it possible to have the function you want to call stored in another variable something like :
string funcToCall ="Addx";
funcToCall;

Solution

 

 

Previous Page    Next Page