L
Lutz Richter
Hi,
given the following code:
-----------------------------
class B
{
public:
B(): Value(99) {}
int Get() { if (this) return Value; else return -1; }
private:
int Value;
};
int main()
{
B* b = 0;
cout << b->Get();
}
-----------------------------
I wonder if this is allowed. I did not have any problem with any
compiler yet. It works! But is this guaranteed?
Unfortunately Stroustrop & Co. do not mention this problem in their
books. If anyone has a documentation about NOT doing the above example,
then please tell me.
Thanks in advance, Lutz.
given the following code:
-----------------------------
class B
{
public:
B(): Value(99) {}
int Get() { if (this) return Value; else return -1; }
private:
int Value;
};
int main()
{
B* b = 0;
cout << b->Get();
}
-----------------------------
I wonder if this is allowed. I did not have any problem with any
compiler yet. It works! But is this guaranteed?
Unfortunately Stroustrop & Co. do not mention this problem in their
books. If anyone has a documentation about NOT doing the above example,
then please tell me.
Thanks in advance, Lutz.