Ebay Interview Question
Software Engineer / DevelopersReflections?!
Why not make a space ship?
Why isn't this good enough bozos?
"by adding getters in the base class and calling it from the derived class object."
#include<iostream>
using namespace std;
class base
{
private:int i;
public:base(int k)
{
i=k;
}
};
class temp
{
public: int i;
};
int main()
{
base b(10);
//temp p;
//p = (temp)b;
cout<< (reinterpret_cast<temp*>(&b))->i<<endl;
}
by adding getters in the base class and calling it from the derived class object.
- Anonymous September 16, 2010