#define private public

(idea) by thbz 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 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 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 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.

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.