Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Target;
- class Test {
- public:
- explicit Test(bool val)
- : str_("This is bool value") { }
- explicit Test(Target* target)
- : str_("This is target") { }
- const std::string& str() const {
- return str_;
- }
- private:
- std::string str_;
- };
- class Target {
- public:
- Target() { }
- void ConstMethod() const {
- Test test(this);
- std::cout << test.str() << std::endl;
- }
- };
- int main(int argc, char **argv) {
- Target target;
- target.ConstMethod();
- return 0;
- }
Add Comment
Please, Sign In to add comment