When defining what data and methods belong to a class, you also get to set accessibility levels so that some things are available for general use while other members are more restricted. Why not just make everything available? Then you don’t have to worry about it, right? Learning proper access control will help you write code that’s actually easier to understand and easier to use. This episode will explain why.
The access levels discussed that apply to both C++ and C# are:
public – Makes members available to any code in the application.
protected – Makes members available only to classes that derive from your class.
private – Allows only the class itself to have access.
And the access levels that apply only to C# are:
internal – Makes members available only to code within the same assembly.
protected internal – Makes members available only to code within the same assembly or to any derived class either in the same assembly or not.
If you want a starter class that you can use to create all of your classes, just go to takeupcode.com/offers where you’ll find links to all our special offers.