-1

Possible Duplicate:
Difference between private, public and protected inheritance in C++

One of the examples in my lecture notes is

class TransportShip : public GameUnit {
    int capacity;

    public:
         ...
}

Why do we need the "public" modifier before the name of the base class? What would it mean if it wasn't there?

Community
  • 1
  • 1
i love stackoverflow
  • 1,555
  • 3
  • 12
  • 24

1 Answers1

1

It would mean that the base class is private.

With a class, the base and all members are private by default. With a struct, the base and all members are public by default.

If the base was private, then only members of the class would be able to access members of the base.

Vaughn Cato
  • 63,448
  • 5
  • 82
  • 132