fork download
  1. #include <cstdint>
  2. #include <cstring>
  3. #include <memory>
  4. #include <iostream>
  5.  
  6. class Goods {
  7. char* name;
  8. uint32_t count;
  9. float price;
  10.  
  11. public:
  12. Goods(){
  13. name = new char[30];
  14. std::memset(name, 0, sizeof *name);
  15. count = 122;
  16. price = 1.5;
  17. }
  18.  
  19. ~Goods(){
  20. delete[] name;
  21. }
  22.  
  23. void Print(){
  24. std::cout << "Goods Name: " << name <<" Count: " << count << " Price: " << price << std::endl;
  25. }
  26. };
  27.  
  28. int main(void)
  29. {
  30. std::unique_ptr<Goods> inputedGoods( new Goods() );
  31. inputedGoods->Print(); //вывод значений
  32. };
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Goods Name:    Count: 122  Price: 1.5