Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class ExampleClass
- {
- const public: // A section that allows everyone to read. Only the class itself may write.
- int iterator;
- public:
- ExampleClass( void ) : iterator(0) {}
- void Increment( void ) { ++iterator; } // Write: allowed within class.
- };
- int main(int, char**)
- {
- ExampleClass example;
- example.Increment();
- std::cout << example.iterator << std::endl; // Read: Allowed everywhere.
- example.iterator = 10; // Write: Not allowed, results in compiler error.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement