C++ – Class vs Struct for data only


Is there any advantage over using a class over a struct in cases such as these?
(note: it will only hold variables, there will never be functions)

class Foo { 
   struct Pos { int x, y, z };
   Pos Position; 


struct Foo {
   struct Pos { int x, y, z } Pos;

Similar questions:

Best Solution

There is no real advantage of using one over the other, in c++, the only difference between a struct and a class is the default visibility of it's members (structs default to public, classes default to private).

Personally, I tend to prefer structs for POD types and use classes for everything else.

EDIT: litb made a good point in the comment so I'm going to quote him here:

one important other difference is that structs derive from other classes/struct public by default, while classes derive privately by default.