PDA

View Full Version : class in the class


baray98
23rd July 2008, 02:17
Guys,

I have some structure definition inside my class and it seems to be c like if your using struct so I want to change my style. but what is the best style to do this.

below is my old code:

class B
{
public:
typedef struct s_A
{
int X;
int Y;
int Z;
} t_A;
protected:
private:
};


I want to change this to


class B
{
public:
class t_A
{
public:
int X;
int Y;
int Z;
} ;
protected:
private:
};



is there any advantage using the old struct vs. the class inside a class style?

i want to still scope the class/struc t_A like below at the end of the day.


B::t_A param;


baray98

ChristianEhrlicher
23rd July 2008, 07:46
There's no difference between a class and a struct. And a struct is not 'old' at all (nor deprecated in some way). So I see no problems here :)

caduel
23rd July 2008, 08:01
There is a (small) difference: all stuff in a class is private by default, in a struct it's public.