I have a class Item that has a non-default constructor and doesn't have a default constructor. There is no default constructor because I don't want to have Item objects with some strange default values around. class Item {    int a;public:    Item(int a) : a(a) {}}Another class User uses Item class and has a method GetItem(Item * item) that returns an Item object by pointer.class User {    Item item;public:   bool SetItem(Item item) {       this->item = item;       return true;  }  bool GetItem(Item * item) { // Can't do Item * GetItem()      *item = this->item;      return true;  }}The problem is when I try to GetItem() from somewhere in my program, I still need to allocate memory for an Item object by using some random values, for example Item anotherItem(999);User user;Item item(5);user.SetItem(item);// Here is the problemItem anotherItem(999); // any random valueuser.GetItem(&anotherItem);What is the best practice to handle such situations? Is it better to have a default constructor?Thank you for your help in advance.
Default constructor and returning by pointer
design patterns;object oriented design
In a situation like yours, there are only a few real optionsAllow creation of a default-constructed Item. This means adding a default constructorReturn a (pointer to a) Item from GetItemTake a Item** or Item*&  and let the passed Item pointer refer to the internal Item of User.None of the options is inherently better than any of the others, although the third one has the big drawback that it allows modification of User content without going through a method of the User class. That opens up the door for violating the constrants that User tries to uphold.