Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication7.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iostream>
- class Parent {
- friend class Priv_two;
- public:
- int m_public;
- private:
- int m_private;
- protected:
- int m_protected;
- };
- class Priv_one : private Parent {
- public:
- int m_public;
- int m_private;
- int m_protected;
- };
- class Priv_two : private Parent {
- Parent pr;
- public:
- void set_m_public(int value) {
- pr.m_public = value;
- }
- void set_m_private(int value) {
- pr.m_private = value;
- }
- void set_m_protected(int value) {
- pr.m_protected = value;
- }
- int get_m_public() {
- return pr.m_public;
- }
- int get_m_private() {
- return pr.m_private;
- }
- int get_m_protected() {
- return pr.m_protected;
- }
- };
- int main()
- {
- std::cout << "Var 1:" << std::endl;
- Priv_one priv_1;
- priv_1.m_public = 0;
- priv_1.m_private = 1;
- priv_1.m_protected = 2;
- std::cout << "public: " << priv_1.m_public << std::endl
- << "private: " << priv_1.m_private << std::endl
- << "protected: " << priv_1.m_protected << std::endl;
- std::cout << std::endl;
- std::cout << "Var 2:" << std::endl;
- Priv_two priv_2;
- priv_2.set_m_public(0);
- priv_2.set_m_private(1);
- priv_2.set_m_protected(2);
- std::cout << "public: " << priv_2.get_m_public() << std::endl
- << "private: " << priv_2.get_m_private() << std::endl
- << "protected: " << priv_2.get_m_protected() << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement