I’m currently making a c++ project and recently came up with a problem, that my code is becoming hard to read. I need to somehow group different parts of code into smaller subgroups for easier navigation (or at least only inside .h file).
I want to make something like this:
class UActor
{
group1
{
func1();
int var1;
}
gropu2
{
func2();
}
}
I found 2 ways to solve this problem - use structures or inner classes, but neither of them let me use variables from main class. Or maybe there is another solution?
There are multiple ways, but if you simply want to split into subgroups you can use different namespaces. You can declare a namespace inside the class declaration and put related functions and variables inside it. Here’s an example: