Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Product
- {
- private:
- int SKU;
- char* brand;
- char* model;
- char* category;
- char* color;
- double size, price;
- int count;
- void erase()
- {
- delete[] this->brand;
- delete[] this->model;
- delete[] this->category;
- delete[] this->color;
- }
- void copy(const Product& other)
- {
- this->brand = new char[strlen(other.brand) + 1];
- this->model = new char[strlen(other.model) + 1];
- this->category = new char[strlen(other.category) + 1];
- this->color = new char[strlen(other.color) + 1];
- this->SKU = other.SKU;
- this->size = other.size;
- this->price = other.price;
- this->count = other.count;
- strcpy_s(this->brand, strlen(other.brand) + 1, other.brand);
- strcpy_s(this->model, strlen(other.model) + 1, other.model);
- strcpy_s(this->category, strlen(other.category) + 1, other.category);
- strcpy_s(this->color, strlen(other.color) + 1, other.color);
- }
- public:
- Product();
- Product(int SKU, const char* brand, const char* model, const char* category, const char* color, double size, double price, int count);
- Product(const Product& other);
- Product& operator =(const Product& other);
- // Getters
- int getSKU() const;
- const char* getBrand() const;
- const char* getModel() const;
- const char* getCategory() const;
- const char* getColor() const;
- double getSize() const;
- double getPrice() const;
- int getCount() const;
- // Setters
- void setSKU(int _SKU);
- void setBrand(const char* _brand);
- void setModel(const char* _model);
- void setCategory(const char* _category);
- void setColor(const char* _color);
- void setSize(double _size);
- void setPrice(double _price);
- void setCount(int _count);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement