Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- class A
- {
- private:
- std::string s;
- protected:
- std::string& to_string() {return s;}
- public:
- A() : s{"default"}{}
- A(const std::string& s) :s{s} {}
- };
- class B : public A
- {
- public:
- using A::A;
- using A::to_string;
- };
- int main()
- {
- B b{"doggie"};
- A& a = b;
- std::cout << b.to_string() << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement