KwickClips Cyber Safety and Ethics · 41 sec · free
Why does obj.bal give a compile error?
Short answer. bal is private.
What should usually be public?
Member functions.
private vs public
| Label | Used by |
|---|---|
| private | class only |
| public | anywhere |
| no label | private |
Remember
| Data: private |
| Functions: public |
| End class with }; |
Why can main not use a private member? Access labels decide who may use a member. Private works only in the class. Public works anywhere. No label means private. Keep data private. Make functions public. End with a semicolon.
This clip is from the full lesson: Classes and Objects with Constructors and Destructors — 7 minutes, with the tables, the quick answers and the whole lesson in text.
Useful for: NIOS Senior Secondary Computer Science (330), Programming All levels C++, Programming All levels C++, Programming All levels C++
More KwickClips from this lesson
Does defining a class use memory for data?41 sec
What does a constructor share with the class?42 sec
Can a destructor take arguments?43 secVoice-over is AI-generated; the script is written and checked by Kajal Ma'am. Confirm anything you plan around against your official board document. We never ask for a password or an OTP.

