- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I'm pretty sure that you're looking for this.
Admin
DO 10 I = 1, NAUSEAM PRINT *, 'THERE''S NOTHING WRONG WITH FORTRAN!' 10 CONTINUEAdmin
Sorry, I forgot a detail (long time since I used the language properly):
DO 10 I = 1, NAUSEAM PRINT *, ' THERE''S NOTHING WRONG WITH FORTRAN!' 10 CONTINUEAdmin
Admin
Admin
Admin
class Widget { ... void * operator new(size_t sz, void *p) { return p; } // placement new operator ... }; class Wgt_Type_One : public Widget ... // etc. enum { WGT_NONE, // for a default that can assert(false) WGT_TYPE_ONE, WGT_TYPE_TWO, WGT_TYPE_THREE, // etc. } widget_id_t; typedef union { char wgt[sizeof(Widget)]; char one[sizeof(Wgt_Type_One)]; char two[sizeof(Wgt_Type_Two)]; char three[sizeof(Wgt_Type_Three)]; // etc. } wgt_stg_t; class Widget_Holder { ... static wgt_stg_t widgets[N]; ... }; Widget *Widget_Holder::Morph_Widget(Widget *wgt, widget_id_t type) { // initialize the object to zero // (in this case the objects didn't use destructors) // this is probably not the best way to do this memset(wgt, 0, sizeof(wgt_stg_t)); // construct the new object with placement new switch (type) { default: case WGT_NONE: new(wgt) Widget(); break; case WGT_TYPE_ONE new(wgt) Wgt_Type_One(); break; case WGT_TYPE_TWO: new(wgt) Wgt_Type_Two(); break; case WGT_TYPE_THREE: new(wgt) Wgt_Type_Three(); break; // etc. } return wgt; }Admin
Why such a complicated approach to accessing protected members? C++ provides us with a simpler solution which, by the way, allows accessing private members as well:
#define private public #define protected public
Admin
I know of one vendor, whose response to a customer needing access to something that was private, told the customer to just #define private public
Admin
Admin
Admin
JAVA is like precision tool used in cataract removing surgery. Pray that you never get cataracts.
Admin
Admin
And that's pretty much the story of TDWTF. The problem is almost never the technology, except to the extent it facilitates stupid coding. The real problem is the developers who should never be allowed near a keyboard...
Admin
No, Java and PHP are TRWTF when used...
Admin
"Getters" and "setters" is a good sign that the code is not OOP.
Admin
You could have just done #define private public
Anwyay, there is a way of hiding implementation completely. Have a pointer to another class which the user of the library knows nothing about.
Admin
Or you could simply:
#define private public
I'm really surprised no one has pointed this out before now.
Admin
Admin
What is this called?
Peculiar Object Oriented Programming?