This is my header file and my CPP file uses the arguments from the main function to initialize these variables with values, But even this is giving me linking errors. How do I solve this issue? The error codes are LNK1120 - unresolved externals and LNK2001 - unresolved external symbol "double g_dailydiscount".
#ifndef FOODORDER_H
#define FOODORDER_H
#include <iostream>
extern double g_dailydiscount;
extern double g_taxrate;
namespace abc {
class FoodOrder {
private:
char m_name[10]{};
char m_desc[25]{};
double m_price;
bool m_isDailySpecial;
public:
FoodOrder();
void read(std::istream& is = std::cin);
void display(std::ostream& os = std::cout);
};
}
#endif // !FOODORDER_H
I tried to declare global variables in header file using extern keyword, But this is still giving me linking errors