// struct members are public by default
struct Image {
int Width;
int Height;
};
// struct inheritance is public by default
struct JpegImage : /*public*/ Image {
int CompressionLevel;
};
int main()
{
struct Image img;
img.Width = 1024;
img.Height = 768;
struct JpegImage jpg;
jpg.Width = 1024;
jpg.Height = 768;
jpg.CompressionLevel = 1;
return 0;
}
With public inheritance: