I'm writing a derived class which calls the superclass constructor but im getting this issue and I cant seem to figure out why. It occurs at line 9
1 2 3 4 5 6 7 8 9 10
#include<string>
#include "Computer.hpp"
class AppleMacbook : public Computer
{
private:
std::string OS = "OS X";
public:
AppleMacbook():Computer(std::string newName, int newStorage);//: public Computer(newName, newStorage);
};
Lines 12 & 14 in the above code give me the error "Too many arguments to function call, expected 0, have 2"
Its an abstract class so should i keep it pure virtual? I'm not too good with ADT or virtual functions yet.
1 2 3 4 5 6
class Printer : public ElectronicDevice
{
public:
virtualvoid print(std::string nJobName, int numPgs) = 0;
virtualvoid scan(std::string nJobName, int numPgs) = 0;
};
derived class:
1 2 3 4 5 6 7 8 9 10
class EpsonPrinter : public Computer, public Printer
{
private:
std::string OS = "Linux";
public:
EpsonPrinter(std::string newName, int newStorage) : Computer(newName, newStorage){};
std::string getOperatingSystem();
void print(std::string nJobName, int numPgs);
void scan(std::string nJobName, int numPgs);
};
Definition in derived class:
1 2 3 4 5 6 7
void EpsonPrinter::print(std::string nJobName, int numPgs)
{
for (int i = 0; i < numPgs; i++)
{
std::cout << "Printing page " << numPgs << " of " << nJobName << std::endl;
}
}
But where is the definition of the print function - that is what does the function do? A pure virtual function must be overridden (redefined) somewhere.
When I say show the error verbatim, I mean directly as it come from the compiler, char for char.
A class can be abstract as long as there is at least 1 pure virtual function, one of the other functions might lend itself towards that better.