classes

This is a discussion on classes within the C++ Programming forums, part of the General Programming Boards category; I actually agree with you in the other thread. The do...while(0) construct is nice in C when function-style macros are ...

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I actually agree with you in the other thread. The do...while(0) construct is nice in C when function-style macros are used, but in C++ you really shouldn't use it.

    I still maintain that a class with all private members that just friends other classes (if it doesn't friend anything, it's useless anyway) should be converted as laserlight suggested.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #17
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,435
    I'm not sure if I understood how to implement it. But will surely give it a look. The issue of classes is still something I'm studying.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #18
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Like this:
    Code:
    class ptr_class_base
    {
    protected:
      class use_count
      {
      public:
        // members here
      };
    };
    
    class ptr_class : private ptr_class_base
    {
      // use_count is visible and accessible here
    };
    
    // Now we suddenly need another class that needs to use use_count.
    class another_ptr_class : private ptr_class_base
    {
      // use_count is visible here - and we didn't have to change it
    };
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 08:04 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 04:38 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21