Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyClass
- {
- public:
- MyClass(string item)
- {
- _item = item.c_str();
- std::cout << "Constructor: " << _item << endl;
- }
- void printItem()
- {
- std::cout << "Print:" << _item << endl;
- }
- private:
- const char* _item;
- };
- int main(int argc, char* argv[])
- {
- MyClass my("www.somewebsite.com");
- my.printItem();
- return 0;
- }
- Constructor: abc
- Print: abc
- Constructor: www.somewebsite.com
- Print:
Add Comment
Please, Sign In to add comment