Guest User

Untitled

a guest
Jan 9th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class MyClass
  2. {
  3. public:
  4. MyClass(string item)
  5. {
  6. _item = item.c_str();
  7. std::cout << "Constructor: " << _item << endl;
  8. }
  9.  
  10. void printItem()
  11. {
  12. std::cout << "Print:" << _item << endl;
  13. }
  14.  
  15. private:
  16. const char* _item;
  17. };
  18.  
  19. int main(int argc, char* argv[])
  20. {
  21. MyClass my("www.somewebsite.com");
  22. my.printItem();
  23. return 0;
  24. }
  25.  
  26. Constructor: abc
  27. Print: abc
  28.  
  29. Constructor: www.somewebsite.com
  30. Print:
Add Comment
Please, Sign In to add comment