Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string.h>
- struct Resolution
- {
- int width;
- int heigth;
- };
- class Display
- {
- private:
- char* name = nullptr;
- Resolution resolution;
- public:
- Display(char* name, Resolution resolution)
- {
- if (name == nullptr)
- {
- this->name = nullptr;
- }
- else
- {
- this->name = new char[strlen(name) + 1];
- strcpy(this->name, name);
- }
- this->resolution = resolution;
- }
- Display(const Display& display)
- {
- this->resolution = display.resolution;
- if (this->name != nullptr)
- {
- delete[] this->name;
- }
- if (display.name == nullptr)
- {
- this->name = nullptr;
- return;
- }
- this->name = new char[strlen(display.name) + 1];
- strcpy(this->name, display.name);
- }
- ~Display()
- {
- delete[] name;
- }
- void setName(char* name)
- {
- if (this->name != nullptr)
- {
- delete[] this->name;
- }
- if (name == nullptr)
- {
- this->name = nullptr;
- return;
- }
- this->name = new char[strlen(name) + 1];
- strcpy(this->name, name);
- }
- char* getName()
- {
- char* toReturn = new char[strlen(this->name) + 1];
- strcpy(toReturn, this->name);
- return toReturn;
- }
- void setResoultion(Resolution resolution)
- {
- this->resolution = resolution;
- }
- Resolution getResolutin()
- {
- return resolution;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment