Thread: strictly speaking standards, do classes get capitalized

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    63

    strictly speaking standards, do classes get capitalized

    Hi, im starting my first project which may eventually become open source, so i want to get the conventions right. Do the names of classes get capitalized.

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Yes, that is what most people do, but I don't think it's defined in the standard. It's usually a good idea to follow the conventions though, as it makes your code more readable to others.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    depends what style you're writing with. It can go either way.

    but usually all caps are used for defines, so they sometimes aren't used for classes.

  4. #4
    Registered User
    Join Date
    Jul 2006
    Posts
    63
    thank you

  5. #5
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Here's my own standard (and the company I used to work for):

    • Class names begin with a capital letter and the first letter of each word is capitalized. Eg. class AntiSpamScanner
    • Public member functions follow the same rules as classes. Eg. ScanFile()
    • Private (or protected) member functions begin with a small letter. Eg. scanFile()
    • Member variables begin with 'm_' and then each word begins with a capital. Eg. std::string m_RemoteFile;
    • Macros are ALL capitals. Eg. #define SQUARE_NUMBER( num ) (num)*(num)
    • Variables begin with a small letter. Eg. std::string fileExtension;

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. compiler isn't enforcing standards strictly enough
    By robatino in forum C++ Programming
    Replies: 25
    Last Post: 12-18-2006, 07:11 PM
  3. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  4. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 05:38 PM
  5. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM