Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- using namespace std;
- class engine
- {
- protected:
- float power, height, width;
- public:
- engine *nast;
- engine();
- engine(float p, float h, float w);
- engine(engine &e);
- void setPower(float p) { power = p; }
- void setHeight(float h) { height = h; }
- void setWidth(float w) { width = w; }
- float getPower() { return power; }
- float getHeight() { return height; }
- float getWidth() { return width; }
- void getAll()
- {
- printf("Power: %0.2f\nHeight: %0.2f\nWidth: %0.2f\n", power, height, width);
- }
- ~engine();
- };
- engine::engine()
- {
- power = 1.0;
- height = 1.0;
- width = 1.0;
- }
- engine::engine(float p, float h, float w)
- {
- power = p;
- height = h;
- width = w;
- }
- engine::engine(engine &e)
- {
- power = e.getPower();
- height = e.getHeight();
- width = e.getWidth();
- }
- engine::~engine()
- {
- delete nast;
- }
- class car
- {
- protected:
- float price;
- char *type;
- public:
- car *nast;
- car();
- car(float p, char *t);
- car(car &c);
- void setPrice(float p) { price = p; }
- void setType(char *s) { type = s; }
- float getPrice() { return price; }
- char *getType() { return type; }
- void getAll()
- {
- printf("Price: %0.2f\nType: %s\n", price, type);
- }
- ~car();
- };
- car::car()
- {
- price = 1.0;
- type = "osobowy";
- }
- car::car(float p, char *t)
- {
- price = p;
- type = t;
- }
- car::car(car &c)
- {
- price = c.getPrice();
- type = c.getType();
- }
- car::~car()
- {
- delete nast;
- }
- class optic
- {
- protected:
- int zoom;
- float weight;
- public:
- optic *nast;
- optic();
- optic(int z, float w);
- optic(optic &o);
- void setZoom(int z) { zoom = z; }
- void setWeight(float w) { weight = w; }
- int getZoom() { return zoom; }
- float getWeight() { return weight; }
- void getAll()
- {
- printf("Zoom: %d\nWeight: %0.2f\n", zoom, weight);
- }
- ~optic();
- };
- optic::optic()
- {
- zoom = 1;
- weight = 1.0;
- }
- optic::optic(int z, float w)
- {
- zoom = z;
- weight = w;
- }
- optic::optic(optic &o)
- {
- zoom = o.getZoom();
- weight = o.getWeight();
- }
- optic::~optic()
- {
- delete nast;
- }
- class person
- {
- protected:
- char *name, *surrname, *email;
- public:
- person *nast;
- person();
- person(char *n, char *s, char *e);
- person(person &p);
- void setName(char *s) { name = s; }
- void setSurrname(char *s) { surrname = s; }
- void setEmail(char *s) { email = s; }
- char *getName() { return name; }
- char *getSurrname() { return surrname; }
- char *getEmail() { return email; }
- void getAll()
- {
- printf("Name: %s\nSurrname: %s\nEmail: %s\n", name, surrname, email);
- }
- ~person();
- };
- person::person()
- {
- name = "Mariusz";
- surrname = "Podstawowy";
- email = "konstruktor@gmail.com";
- }
- person::person(char *n, char *s, char *e)
- {
- name = n;
- surrname = s;
- email = e;
- }
- person::person(person &p)
- {
- name = p.getName();
- surrname = p.getSurrname();
- email = p.getEmail();
- }
- person::~person()
- {
- delete nast;
- }
- int main()
- {
- optic *head = NULL, *wsk;
- wsk = head;
- for (int i = 0; i < 5; i++)
- {
- if (head == NULL)
- {
- head = wsk = new optic(5, 1.0);
- }
- else
- {
- wsk->nast = new optic();
- wsk = wsk->nast;
- }
- }
- wsk = head;
- while (wsk != NULL)
- {
- wsk->getAll();
- wsk = wsk->nast;
- }
- system("Pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement