Guest User

Untitled

a guest
Jun 25th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. class Target;
  3.  
  4. class Test {
  5. public:
  6. explicit Test(bool val)
  7. : str_("This is bool value") { }
  8. explicit Test(Target* target)
  9. : str_("This is target") { }
  10. const std::string& str() const {
  11. return str_;
  12. }
  13. private:
  14. std::string str_;
  15. };
  16.  
  17. class Target {
  18. public:
  19. Target() { }
  20. void ConstMethod() const {
  21. Test test(this);
  22. std::cout << test.str() << std::endl;
  23. }
  24. };
  25.  
  26. int main(int argc, char **argv) {
  27. Target target;
  28. target.ConstMethod();
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment