Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Test
- {
- public:
- void displayPrivateNo()
- {
- std::cout << privateNo << std::endl;
- }
- private:
- int privateNo{ 1337 };
- };
- int main()
- {
- Test test;
- test.displayPrivateNo(); //Works because displayPrivateNo calls the integer privateNo within the class
- //std::cout << test.privateNo << std::endl; //Doesnt work because privateNo gets called outside of the class
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement