Thread: is this style of c++ programming good?

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    1

    is this style of c++ programming good?

    Hi,
    I'm thinking about implementing the all the function details in the header file, for example I have the following code in Box.h :

    class Box{
    public:
    Box(int num){
    this->num = num;
    }

    void Rotate(){
    //many lines of code here
    }
    private:
    int num;
    };

    Instead of writing Box::Rotate(){
    //many lines of code here
    } in my cpp file , I implement the Rotate function in the header file.
    this style is a little bit like java

    Do you think this is a good coding style?

  2. #2
    Registered User Dr. Bebop's Avatar
    Join Date
    Sep 2002
    Posts
    96
    Usually it's best to have the declarations in the header file and definitions in a source file. Putting the definition of methods in the class makes them inline and that can bloat your code a lot if you aren't careful.
    Processing error: Stupidity detected.
    ------------------------------
    Dr. Bebop
    Windows XP Professional Ed.
    Microsoft Visual Studio 6

  3. #3
    Registered User JTtheCPPgod's Avatar
    Join Date
    Dec 2001
    Posts
    44

    Thumbs up

    You forgot code brackets.
    Now you must diiiiiiieeeee
    "No! I must have my delicious cupcakes, my sweet cakey treasures, piping hot from their 40 watt WOMB!!!"
    --Captain Murphy

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  2. How to write a program as good as possible?
    By jinhao in forum C++ Programming
    Replies: 9
    Last Post: 06-15-2005, 12:59 PM
  3. Good resources for maths and electronics
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-22-2004, 04:23 PM
  4. Good C++ books for a begginer
    By Rare177 in forum C++ Programming
    Replies: 13
    Last Post: 06-22-2004, 04:30 PM
  5. i need links to good windows tuts...
    By Jackmar in forum Windows Programming
    Replies: 3
    Last Post: 05-18-2002, 11:16 PM