Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- using namespace std;
- class device {
- public:
- device(string name, string description, int price) : name_(name), description_(description), price_(price) {}
- void set_name(string name) {
- name_ = name;
- }
- void set_description(string description) {
- description_ = description;
- }
- void set_price(int price) {
- price_ = price;
- }
- virtual void get_info() = 0;
- protected:
- string name_;
- string description_;
- int price_;
- };
- class computer : public device {
- public:
- computer(string name, string description, int price, int CPU, int RAM, int disc_space) : device(name, description, price), RAM_(RAM), CPU_(CPU), disc_space_(disc_space) {}
- void set_RAM(int RAM) {
- RAM_ = RAM;
- }
- void set_CPU(int CPU) {
- CPU_ = CPU;
- }
- void set_disc_space(int disc_space) {
- disc_space_ = disc_space;
- }
- virtual void get_info() {
- cout << name_ << " " << description_ << " " << price_ << " " << RAM_ << " " << CPU_ << " " << disc_space_ << endl;
- }
- protected:
- int RAM_; // объем оперативной памяти
- int CPU_; // количество ядер процессора
- int disc_space_; // объем диска
- };
- int main() {
- setlocale(LC_ALL, "ru");
- computer pc("Intel", "Игровой ПК", 100000, 32, 6, 500);
- pc.get_info();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement