Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Computer{
- private:
- string manufacturer;
- int ram;
- double cpu;
- public:
- Computer(string manufacturer = "", int ram = 0, double cpu = 0.0) {
- this->manufacturer = manufacturer;
- this->ram = ram;
- this->cpu = cpu;
- }
- };
- class PCStore {
- private:
- Computer *computers;
- int n;
- int sz;
- public:
- PCStore() {
- computers = new Computer[10];
- n = 0;
- sz = 10;
- }
- void add_computer(Computer c) {
- if(n == sz) {
- Computer *copy_array = new Computer[sz];
- for(int i = 0; i < n; i++) {
- copy_array[i] = computers[i];
- }
- sz *= 2;
- computers = new Computer[sz];
- for(int i = 0; i < n; i++) {
- computers[i] = copy_array[i];
- }
- }
- computers[n] = c;
- n++;
- }
- };
- int main()
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement