Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cout;
- using std::endl;
- using std::string;
- class MyClass
- {
- public:
- MyClass(string val="default")
- {
- this->val=val;
- }
- void output(MyClass &subject)
- {
- cout << subject.val << endl;
- }
- protected:
- string val;
- };
- int main()
- {
- MyClass obj1;
- MyClass obj2("hello world");
- obj1.output(obj2);
- return 0;
- }
- //$ ./a.out
- //hello world
Advertisement
Add Comment
Please, Sign In to add comment