Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- // Klasa o nazwie ClassA (jest to nowy typ dostępny dla funkcji).
- class ClassA
- {
- public:
- // Konstruktor domyślny obiektu ClassA.
- ClassA(int prv = 0) {
- mPrivate = prv;
- }
- void print(void) const {
- cout << "mPrivate = " << mPrivate << endl;
- }
- void setPrivate(int prv) {
- mPrivate = prv;
- }
- int getPrivate(void) const {
- return mPrivate;
- }
- private:
- // Składowa prywatna.
- int mPrivate;
- };
- int main()
- {
- ClassA a(10);
- a.print();
- a.setPrivate(12);
- a.print();
- a.setPrivate(14);
- cout << "a.getPrivate() = " << a.getPrivate() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment