Class with pointer to same class

This is a discussion on Class with pointer to same class within the C++ Programming forums, part of the General Programming Boards category; Should you cut a sandwich in horizontally or diagonally?...

  1. #16
    Registered User taelmx's Avatar
    Join Date
    Oct 2006
    Location
    Japan
    Posts
    55
    Should you cut a sandwich in horizontally or diagonally?

  2. #17
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,532
    > Thanks for all the help everyone, one more piece of the C++ puzzle clear in my head, eventhough its now polluted somewhat with sandwich annolgies .

    Well, being a wet blanket and not getting into the sandwich debate, I would advise you to always declare your variables one per line and use * and & next to the type, instead of the identifier.

    Code:
    int* somename;
    int& someothername;
    int yetanothername;
    The above has the advantage of quickly bringing out the real type of the name. It also doesn't hide from your skimming routine the names that have been declared.

    Code:
    int *somename, *someothername, yetanothername;
    May look fancy, but makes it harder to read when skimming the code trying to find the type of some variable 100 lines below.

    Code:
    int *somename;
    is ok of course. But when seen alone. In function declarations, for instance can easily hide the real type when reading the code quickly.

    Just my opinion. Whatever yuou do, the real advise is... be consistent.
    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
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Should you cut a sandwich in horizontally or diagonally?
    I usually don't cut them.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

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

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Initializing a pointer in a class.
    By gpr1me in forum C++ Programming
    Replies: 3
    Last Post: 03-22-2006, 03:05 PM
  3. class passing a pointer to self to other class
    By daioyayubi in forum C++ Programming
    Replies: 3
    Last Post: 09-05-2005, 10:25 AM
  4. base class pointer problems
    By ... in forum C++ Programming
    Replies: 3
    Last Post: 11-16-2003, 11:27 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM

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