Saturday, October 8, 2011

Interview

Today I was been in NTC Protey company. I was wrote tests about programming on C++. They told me, we're call you today or may be tomorrow and report you result. Some questions from test i wrote here may  be someone will be interesting. What questions asks in interview   russians IT-company. The truth it is a first interview, they told me, will be a second interview if i approached them.

class A {
public:
A ();
virtual void f();
virtual ~A ();
private:
/* data */
};

class B : public A{
public:
B();
virtual void f();
virtual ~B();
private:
/* data */
};

void A::f()
{
std::cout<<"A"<<std::endl;
}

void B::f()
{
std::cout<<"B"<<endl;
}

A::A(){}
B::B(){}
A::~A(){}
B::~B(){}

int ff(int bb)
{
return bb++;
}

int ff(A aa)
{
aa.f();
}


int main(int argc, const char *argv[])
{
A *a = new B();
a->f();
ff(*a);
cout<<ff(1)<<endl;
return 0;
}

What will be printed?

No comments:

Post a Comment