Unresolved external symbols

Hi forum,

I am running into an issue that is not allowing me to compile my program. I get external symbol errors and "multiply defined symbols found." I am not sure why this is happening, but any help would be much appreciated.. Im going to post all of my code, and all 5 errors, so it'd be easier to CTRL+F/copy/paste for something specific. Im just looking for some sort of direction, because everything is going well, and then boom, I have no idea where I am and what to do.I was thinking of using FORCE:[MULTIPLE|UNRESOLVED], but G++ will complain upon submission.

The 4 errors are:
1.
LNK2005: "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl sict::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,class sict::Product &)" (??5sict@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@std@@AAV12@AAVProduct@0@@Z) already defined in MyProduct.obj

2.
LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sict::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class sict::Product const &)" (??6sict@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@ABVProduct@0@@Z) already defined in MyProduct.obj

3.
LNK2005: "double __cdecl sict::operator+=(double &,class sict::Product const &)" (??Ysict@@YANAANABVProduct@0@@Z) already defined in MyProduct.obj

4. LNK2005: "class sict::Product * __cdecl sict::CreateProduct(void)" (?CreateProduct@sict@@YAPAVProduct@1@XZ) already defined in MyProduct.obj



//


And the code: (if there's anything missing, please let me know)

http://cpp.sh/36mhi
Last edited on
Yeah template errors can be a mess...

But focus on the first error you see, first.
292:68: warning: multi-character character constant [-Wmultichar]
In member function 'void sict::NonPerishable::setEmpty(char)':

This means you're trying to define a single char type as multiple actual characters.
<< "Price after tax: " << (taxable) ? price * (1 + tax_rate) : 'N/A';
'N/A' is not valid syntax. Double quotes are needed to define string literals, not single quotes.

292:41: error: operands to ?: have different types 'double' and 'const char*'
In function 'std::ostream& sict::operator<<(std::ostream&, const sict::Product&)':

Also, you can't use the ternary operator ?: to mix output types. price * (1 + tax_rate) is a double, while "N/A" is a string literal.
Just save yourself the trouble and turn it into a regular if statement.
1
2
3
4
5
os << "Price after tax: ";
if (taxable)
    os << price * (1 + tax_rate);
else
    os << "N/A";


EDIT: I seem to straying from your actual post. Sorry about that. You are having some linker errors. Try just cleaning your project and rebuilding without pre-existing object files.
Last edited on
Topic archived. No new replies allowed.