product check out program
ERROR: [Linker error] undefined reference to `FreshFood::FreshFood()'
I dont really know why that error is returned yet everything seems fine to me.Its a program to scan items in a shop.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
class Product
{
private:
long int barCode;
std:: string productName;
public:
Product(){barCode = 00000000000000;
productName = "productName";}
Product (int a , std::string b )
{
barCode = a;
productName = b;
}
int setbarCode(long int a);
int getbarCode(){return barCode;}
void printbarCode();
void scanbarCode();
};
//--------------------------------------------- prepacked food class -----------------------------------
class PrepackedFood : public Product
{
private:
int Package;
double UnitPrice;
public:
PrepackedFood (){};
int setPackage(int p);
int getPackage(){return Package;}
double setUnitPrice(double);
double getUnitPrice()
{
double price, weight, Package;
price=Package*UnitPrice;
return price;
}
};
//----------------------------------------------- fresh food -----------------------------------------------
class FreshFood : public Product
{
private:
double Weight;
double PricePerKg;
public:
FreshFood (){};
double setweight(){return Weight;}
double getWeight();
double getprice()
{
double price, weight, PricePerKg;
price=weight*PricePerKg;
return price;
}
};
|
Last edited on
It happens because constructor is declared but not implemented. You could delete line 52 or change
FreshFood ();
into
FreshFood (){ }
I did so, however there was no change!
maybe your program just need a main() function?
and delete the ";" in line 45/52
Topic archived. No new replies allowed.