Possible Duplicate:
Calling virtual functions inside constructors
first of all below code is not working visual c++ , but workin with bloodshed
output is 0 , but acc. to me it shud be 1 ; can anyone explain this
#include<iostream>
using namespace std;
class shape
{
public:
virtual void print() const =0;
virtual double area() { return 0.0;}
};
class point : public shape
{
int x;
int y;
public :
point(int a=11, int b=11)
{
x=a;
shape *s;
s=this;
cout<<s->area();
y=b;
}
double area()const {return 1.0;}
void print() const
{
cout<<"\nPoint\n";
cout<<x<<"\t"<<y;
}
};
int main()
{
point p(1,2);
return 0;
}