Thread: class definition

  1. #1
    Registered User
    Join Date
    Dec 2009

    class definition


    I use C or java mostly, but not C++. , Recently, I must start to write c++ code and have a question about Class definition.

    I have seen Class are defined in either a header (.h) or an implementation (.cpp) file. Is there general rules or guidelines for where to place a C++ Class? Or, pretty much whatever you want.


  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    A class might be placed into an implementation file if it is supposed to be implementation detail, in which case its definition will likely be in an unnamed namespace. Other than that, class definitions are generally placed in header files.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. class definition error
    By rahulsk1947 in forum C++ Programming
    Replies: 4
    Last Post: 05-16-2009, 11:26 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 07:16 AM
  4. Class Definition?
    By Jamina in forum C++ Programming
    Replies: 4
    Last Post: 08-07-2003, 11:12 PM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM