Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string.h>
- class RAM
- {
- private:
- char* name;
- int frequency;
- public:
- RAM(char* name, int frequency)
- {
- if (name == nullptr)
- {
- this->name = nullptr;
- }
- else
- {
- this->name = new char[strlen(name) + 1];
- strcpy(this->name, name);
- }
- this->frequency = frequency;
- }
- RAM(const RAM& ram)
- {
- this->frequency = ram.frequency;
- if (this->name != nullptr)
- {
- delete[] this->name;
- }
- if (ram.name == nullptr)
- {
- this->name = nullptr;
- return;
- }
- this->name = new char[strlen(ram.name) + 1];
- strcpy(this->name, ram.name);
- }
- ~RAM()
- {
- if (name != nullptr)
- {
- 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 setFrequency(int frequency)
- {
- this->frequency = frequency;
- }
- int getsetFrequency()
- {
- return frequency;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment