www.digitalmars.com         C & C++   DMDScript  

D - Strange behavior of typedef

reply Matthias Becker <Matthias_member pathlink.com> writes:
class MyClass {}
typdef MyTypedef {}
class MyDerived : MyClass {}
class MyTypedefDerived : MyTypedef {}

int main ()
{
MyClass foo = new MyDerived();  // works fine
MyTypedef bar = new MyTypedefDerived();  // doesn't work :(


return 0;
}
Jan 27 2004
parent reply "Walter" <walter digitalmars.com> writes:
"Matthias Becker" <Matthias_member pathlink.com> wrote in message
news:bv5i4g$1g73$1 digitaldaemon.com...
 class MyClass {}
 typdef MyTypedef {}
I don't know what you meant to happen here, but "typdef" should be "typedef", and the syntax is for a class declaration, not a typedef.
 class MyDerived : MyClass {}
 class MyTypedefDerived : MyTypedef {}

 int main ()
 {
 MyClass foo = new MyDerived();  // works fine
 MyTypedef bar = new MyTypedefDerived();  // doesn't work :(


 return 0;
 }
Jan 28 2004
parent Matthias Becker <Matthias_member pathlink.com> writes:
"Matthias Becker" <Matthias_member pathlink.com> wrote in message
news:bv5i4g$1g73$1 digitaldaemon.com...
 class MyClass {}
 typdef MyTypedef {}
I don't know what you meant to happen here, but "typdef" should be "typedef", and the syntax is for a class declaration, not a typedef.
Sorry, I ment. class MyClass {} typdef MyClass MyTypedef; Damn. I had this at home, but hadn't have the time to report it. So I did it the next day at work (so I caouldn't use copy&paste).
 class MyDerived : MyClass {}
 class MyTypedefDerived : MyTypedef {}

 int main ()
 {
 MyClass foo = new MyDerived();  // works fine
 MyTypedef bar = new MyTypedefDerived();  // doesn't work :(


 return 0;
 }
Jan 29 2004