Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Test{
- private:
- char* name;
- double price;
- double time;
- public:
- Test(const char* =" ", double = 0, double = 0);
- virtual ~Test(){
- delete [] name;
- }
- Test(const Test& rhs){
- strcpy_s(name, (strlen(rhs.name) + 1), rhs.name);
- price = rhs.price;
- time = rhs.time;
- }
- Test& operator=(const Test& other){
- if (this != &other){
- delete [] name;
- name = new char[strlen(other.name)+1];
- strcpy_s(name, (strlen(other.name) + 1), other.name);
- price = other.price;
- time = other.time;
- }
- return *this;
- }
- void setName(const char* _name){
- delete [] name;
- name = new char[strlen(_name)+1];
- strcpy_s(name, (strlen(_name)+1), _name);
- }
- void setPrice(double _price){
- price = _price;
- }
- void setTime(double _time){
- time = _time;
- }
- virtual double getPrice()const{
- return price;
- }
- virtual double getTime()const{
- return time;
- }
- const char* getName()const{
- return name;
- }
- virtual void print()const;
- };
- class Pack{
- private:
- Test** t;
- int size_t;
- public:
- Pack(const char*);
- ~Pack();
- virtual double getPrice()const;
- virtual double getTime()const;
- virtual void print()const;
- void addTest(const Test&);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement