小白求助大神們 請問這個錯在哪呀 急
#include "stdafx.h"
#include<iostream>
using namespace std;
class Car
{
public:
virtual void Drive() {cout<<"o"<<endl;};
};
class Benz :public Car
{
public:
virtual void Drive(){
cout << "Benz-舒適" << endl;
}
};
class BMW :public Car
{
public:
virtual void Drive(){
cout << "BMW-操控" << endl;
}
};
void Test()
{
Car* pcar;
pcar->Drive();
Car* pBenz = new Benz;
pBenz->Drive();
Car* pBMW = new BMW;
pBMW->Drive();
}
int main()
{
Test();
system("pause");
return 0;
}
uj5u.com熱心網友回復:
Car* pcar = new Car();pcar->Drive();
-------------------------
---一條精致的小尾巴---
https://bbs.gnsoft.ltd
-------------------------
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/49256.html
標籤:新手樂園
上一篇:c++遞回尾呼叫失敗
