1
4

1 回答 1

6

error: ‘Car’ does not name a type

At the point of

static Car* createCar()

Car is not yet known. Move the definition of class Car above the function

error: ‘string’ does not name a type In function ‘void useVehicle()’:

#include <string>

also use std:: to qualify string

error: ‘createCar’ is not a member of ‘Vehicle’</p>

This error will disappear once you fix the other two issues. The compiler wasn't able to parse the function declaration because it didn't know what its return type was.

于 2013-08-15T12:39:43.000 回答