C++电脑组装项目(涉及知识点:多态)

需求:

C++电脑组装项目(涉及知识点:多态)_第1张图片

#include 
#include "Computer.h"
#include "AbstractCpu.h"
#include "AbstractMemory.h"
#include "AbstractVideoCard.h"
#include "IntelCpu.h"
#include "IntelMemory.h"
#include "IntelVideoCard.h"

using namespace std;

int main()
{   
    AbstractCpu* cpu = new IntelCpu;
    AbstractMemory* memory = new IntelMemory;
    AbstractVideoCard* videocard = new IntelVideoCard;

     //为什么这样报错?
    // Computer c = Computer(cpu,memory,videocard);
   
    Computer* computer = new Computer(cpu,videocard,memory);

    computer->run();

    delete computer;
    delete cpu;
    delete memory;
    delete videocard;


    return 0;
}

你可能感兴趣的:(C++笔记,c++)