当我继承基类时,它告诉我没有这样的类
这是增强的.h:
class enhanced: public changeDispenser // <--------where error is occuring
{
public:
void changeStatus();
// Function: Lets the user know how much of each coin is in the machine
enhanced(int);
// Constructor
// Sets the Dollar amount to what the User wants
void changeLoad(int);
// Function: Loads what change the user requests into the Coin Machine
int dispenseChange(int);
// Function: Takes the users amount of cents requests and dispenses it to the user
private:
int dollar;
};
这是增强的.cpp:
#include "enhanced.h"
#include <iostream>
using namespace std;
enhanced::enhanced(int dol)
{
dollar = dol;
}
void enhanced::changeStatus()
{
cout << dollar << " dollars, ";
changeDispenser::changeStatus();
}
void enhanced::changeLoad(int d)
{
dollar = dollar + d;
//changeDispenser::changeLoad;
}
这是changeDispenser.h:
class changeDispenser
{
public:
void changeStatus();
// Function: Lets the user know how much of each coin is in the machine
changeDispenser(int, int, int, int);
// Constructor
// Sets the Quarters, Dimes, Nickels, and Pennies to what the User wants
void changeLoad(int, int, int, int);
// Function: Loads what change the user requests into the Coin Machine
int dispenseChange(int);
// Function: Takes the users amount of cents requests and dispenses it to the user
private:
int quarter;
int dime;
int nickel;
int penny;
};
我没有包含驱动程序文件或 changeDispenser imp 文件,但在驱动程序中,这些已包含
#include "changeDispenser.h"
#include "enhanced.h"