I'm getting this error when i make an object of a child class which implements virtual function of Base class.
error LNK2001: unresolved external symbol "public: virtual void __thiscall CateringOrder::[Order]::calcTotals(void)" (?calcTotals@?QOrder@@CateringOrder@@UAEXXZ)
whereas my code is
class Order
{
private:
float SANDWICH_PRICE;
float TOCOS_PRICE;
public:
string customerType;
int NumberOfSandwiches;
int NumberOfTacos;
float SandwichSubtotal;
float Subtotal;
float TacosSubtotal;
float Total;
int TotalItems;
virtual void calcTotals()=0;
virtual ~Order(){};
};
//child class 1
class ConsumerOrder:public Order{
private:
float SALES_TAX_RATE;
public:
string CustomerName;
float SalesTax;
void calcTotals() override;
string ToString();
};
// child class 2
class CateringOrder: public Order
{
public:
string CustomerCode;
float DeliveryFee;
bool PreferredCustomer;
void Order::calcTotals(void) override;
string ToString();
};
//other class
static class Validation
{
public:
bool CheckCustomerCode();
bool CheckCustomerType();
float CheckDeliveryFee();
int CheckItem();
};
now when i make object of base class then it shows error after compiling it.
bool Validation::CheckCustomerCode()
{
CateringOrder obj;
string tempCode = obj.CustomerCode;
return true;
}