I often think about avoiding "forgetting member variables" in toString-methods, initialisation lists,... Further I often see logic of the object itself (data usage and manipulation) mixed up with pure data-care (initialisation, get/set, constructor for copy,rval-copy,bla).
If it comes to really big classes with a lot of methods and member variables it gets pretty confusing.
So what's the reason, why programmers do not put all the variables together in one nested struct that does only do data care and extracting the buisiness-logic?
I'd imagine
class NestedStructTesting
{
public:
typedef struct TData
{
private:
int var1;
float var2;
public:
int getVar1(){return var1;};
void setvar1(int value){var1 = value;};
int getVar2(){return var2;};
void setvar2(int value){var2 = value;};
TData()
{
var1 = 0;
var2 = 0;
}
};
TData Data;
NestedStructTesting(void)
: Data()
{
};
};
maybe with an outside-call like: NestedStructTesting st; st.Data.setvar1()
( I don't have any experience using it in big projects, as I didn't build up one, yet )