SHARE
TWEET

Untitled

a guest Nov 25th, 2015 156 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     const char& Item::name() const{
  2.             char& name = *_name;
  3.             return name;
  4.     }
  5.  
  6. Here's your problem. A char& is a reference to only 1 char. *_name = *(_name + 0) = _name[0]. So you only get the first character.
  7.  
  8. char* as strings is for C. In C++, you should use std::string:
  9.  
  10.    const string Item::name() const{
  11.            string name(_name);
  12.            return name;
  13.    }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top