Author Topic: Code Grouping  (Read 3445 times)

bahdom

  • Guest
Code Grouping
« on: December 28, 2008, 06:02:11 am »
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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Grouping
« Reply #1 on: December 28, 2008, 08:01:34 am »
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.

Offline Ganbito

  • Multiple posting newcomer
  • *
  • Posts: 79
Re: Code Grouping
« Reply #2 on: December 28, 2008, 12:58:16 pm »
When I want to group code inside a file, I use:
Code
//{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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Grouping
« Reply #3 on: December 28, 2008, 01:45:13 pm »
When I want to group code inside a file, I use:
Code
//{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.