Archived

This topic is now archived and is closed to further replies.

ELS1

organizing my code....?

Recommended Posts

im making a header file that will contain around 50 functions..ive written around 5 so far and they look SLOPPY! void blah(char* string) { //stuff } void close32bitwindow(HWND window) { //stuff } and so on and so on...i was wondering if there is a nicer way of organizing code than this? there are some recursive TONS of recursive functions here also. im new in c...ive been using vb and such...just want some tips and the such how to organize and optimize my code...thanks a lot!

Share this post


Link to post
Share on other sites
Do you write the fuction body in the header file? That´s not how you are supposed to do it. Also organize your fuctions in classes with many diffrent cpp and header files. And if a class grow to big (more then 3000 lines) split it up in 2 cpp files and 1 header file (or separate the class into several smaller more specialized classes).

hny,



Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites
quote:
Original post by Zeblar Nagrim
Do you write the fuction body in the header file? That´s not how you are supposed to do it. Also organize your fuctions in classes with many diffrent cpp and header files. And if a class grow to big (more then 3000 lines) split it up in 2 cpp files and 1 header file (or separate the class into several smaller more specialized classes).

hny,



Zeblar Nagrim, Lord of Chaos


so its better to include all the function prototypes in the header file and the function body in a separate .c file? i just found a great c tutorial and am trying to follow the rules correctly.

Share this post


Link to post
Share on other sites
so its better to include all the function prototypes in the header file and the function body in a separate .c file? i just found a great c tutorial and am trying to follow the rules correctly.

Share this post


Link to post
Share on other sites
quote:
Original post by ELS1
so its better to include all the function prototypes in the header file and the function body in a separate .c file?

Yes, that''s better. If you include a header with full (non-static and non-inline) functions in more than one source file your compiler will complain. So, basically, just put an extern prototype in the header.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites