Everything2
Near Matches
Ignore Exact
Full Text
Everything2

#define private public

created by thbz

(idea) by thbz (1 mon) (print)   ?   1 C! I like it! Wed Nov 29 2000 at 8:43:38

If a book about C++ tells you that you cannot use private member variables from another class, just throw the book away. Real Programmers, when they are forced to use C++, start their programs with the following line, before including any header file, and they never have OOP headaches:

   #define private public

Never underestimate the power of C++.


(idea) by ariels (4.2 d) (print)   ?   I like it! Thu Dec 21 2000 at 15:08:41

Easy. Even a stubborn C programmer like myself knows that the default mode in class definitions is private:. Just write your code like this...
  class C {
    // this is all private:
    int cantTouchThis;
  public:
    // ...
  };

BC++PFHs would be advised to #define class struct, just in case.


(idea) by everyone (4.2 wk) (print)   ?   I like it! Thu Dec 21 2000 at 19:35:22

At the top of the code? Not needed.
    -Dprivate=public -Dprotected=public -Dclass=struct
In your compiler's command line. Oh, yes, and I added "protected" too, you forgot that one. Of course, we all know this is bad practice.

(idea) by DrPizza (5.3 y) (print)   ?   I like it! Sun Feb 09 2003 at 15:49:43

#define private public is, strictly speaking, illegal. Section 17.4.3.1.1 of the C++ Standard states that "Nor shall such a translation unit define macros for names lexically identical to keywords." -- which means that an implementation would be permitted, if it so desired, to reject programs attempting the definition.

This would probably be no bad thing, though I'm not aware of any compiler (or preprocessor) that attempts to enforce this rule.


printable version
chaos

using public variables in c++ classes The C++ Programming Language Freakshow love song fallacy Yes, dammit I am sure I want to delete it. While you're at it, empty the trash, too!
#define Ladies From Hell C++ Fem-Porn
Custer's Last Stand black pudding PIC OOP
Oh, False One, You Have Deceived Me JAA Private Pilot License Bastard Operator from Hell cosplay
shortboard The Summer Job from Hell Where do you consider Home? Sleight
15 to 1 illegal practice Private Parts
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Drink up!
War on Iraq 2003
Godspeed You Black Emperor!
E2 Link and Logger Client
Tour de France
You too can spend four years
Civilization
Sins of the World
Noetherian
Six Sigma
The Guru got a girlfriend
The Little Prince
e2interface
Year of the rooster
New Writeups
Ouzo
PETA becomes you, a proposed future(fiction)
Ereneta
Stone Soup, Part Two(person)
jjen
Sorrier than I ever thought I would be(personal)
locke baron
Moskva class antisubmarine cruiser(thing)
Wuukiee
May 15, 2008(idea)
locke baron
Kuznetsov class aircraft carrier(thing)
_lesra
for abby(thing)
Adaptive Child
Annie's garden salsa(recipe)
Simulacron3
Zig-Zag(thing)
Ouzo
Special Grilled Cheese(fiction)
Noung
Tiananmen Square Massacre(idea)
aneurin
Lord St Clair(person)
artman2003
Assholes and Douchebags: A Comparison(person)
locke baron
Tyan Thunder K8WE(thing)
locke baron
Udaloy class destroyer(thing)
This affordable entertainment brought to you by The Everything Development Company