That is all.
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Stupid C++ and stupid classes not being able to call virtual members from constructors. Stupid annoying stupid rrrghhh stupid hate hate hate DIE.
That is all.
That is all.
Previous Entry
My Narcotics Addiction
Next Entry
Haha creativity.
Comments
![Julian90](/static/media/user/generic-user.png)
Julian90
I know your probally whining for a reason but thats one of the few things where I think c++ took the logical choice, if you could call virtual functions from in the constructor then you might call a virtual function from a base class which acesses the members of a derived class before they are initialized so its "cant call them" or "potentially undefined behaviour if you call them", I know which I prefer ;).
April 22, 2007 06:49 AM
![ApochPiQ](https://uploads.gamedev.net/monthly_2017_06/321649.thumb.png.c7e3a9cb02b37a485d4cf9b8c638b8e7.png)
Of course it's logical. The only way to get around it would be to force the compilers to basically do two-phase construction transparently (i.e. init the vtable first and then call the normal constructors) which introduces all kinds of nasty problems of its own, and violates the well-known C++ design policy of "you don't pay for what you don't use."
The problem is it ruins a few designs that would otherwise be very elegant, especially when it comes to building classes in the RAII style. Of course, one could make a very good argument that anyone looking for ease of elegant design should steer well clear of C++ in the first place.
The problem is it ruins a few designs that would otherwise be very elegant, especially when it comes to building classes in the RAII style. Of course, one could make a very good argument that anyone looking for ease of elegant design should steer well clear of C++ in the first place.
April 22, 2007 06:49 PM
![Julian90](/static/media/user/generic-user.png)
ok then, I guess if you really need it you could get the same effect by passing a member function pointer to the class constructor and hide it from users by setting it to a default value, its a bit of extra work since you have to pass the new pointer to the base class in each derived class constructor but its better then nothing.
April 23, 2007 02:26 AM
Advertisement
Latest Entries
A Few Farewells
14586 views
Code Reuse In Actual Practice
16462 views
Source-Level Debugging For Epoch Programs
4988 views
Using Poison to Reverse Engineer Code
154266 views
Using Poison to Reverse Engineer Code
3622 views
Debugging Information Success
2922 views
Debugging Information Success
5463 views
Debugging Epoch Programs
3133 views
Debugging Epoch Programs
7440 views
Epoch 64-bit compiler progress
2625 views
Advertisement