News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Code Grouping

Started by bahdom, December 28, 2008, 06:02:11 AM

Previous topic - Next topic

bahdom

Is there some way to group related code inside a class? For example, if dealing with a renderer class I'd like to group all the methods related to dealing with surfaces, all those with displaying on screen, etc.
I tried doing this with { }, but I got an error message from the compiler. Is there some other way of doing this in CodeBlocks?

Thanks

ollydbg

Please give some piece of your code. Thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Ganbito

When I want to group code inside a file, I use:

//{Meaningful section start
...(code to group)
//}Meaningful section end


As the brackets are into comments, compiler don't try to parse them and don't throw an error but codeblocks notice them and put an '+' symbol on the margin so I can hide an show this section, regardless of that is not a code section following the language rules.

ollydbg

Quote from: Ganbito on December 28, 2008, 12:58:16 PM
When I want to group code inside a file, I use:

//{Meaningful section start
...(code to group)
//}Meaningful section end


As the brackets are into comments, compiler don't try to parse them and don't throw an error but codeblocks notice them and put an '+' symbol on the margin so I can hide an show this section, regardless of that is not a code section following the language rules.
This is an informative message.
Thanks for sharing the trick.
It should be added to wiki page, :D.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.