codex
codex

Reputation: 303

C++ undefined reference to method

I am new to C++ and am attempting to define an object class that gives the ability to do large number arithmetic, utilizing a string as the internal structure for the number. One of the arithmetic methods I am attempting to utilize is addition, by overloading the '+' operator and utilizing a helper method called add(string a, string b) that I have defined. However, when I compile with g++, I receive this error message: undefined reference to huge_number::add collect2: ld returned 1 exit status. I've searched around quite a bit to try and determine the problem but have yet to find the solution. If someone could please help, I imagine the solution is quite simple and I am just missing it for some reason.

Upvotes: 0

Views: 92

Answers (1)

Jack
Jack

Reputation: 133577

string add (string a, string b)

you are forgetting class name specifier for add in your .cpp:

string huge_number::add (string a, string b)

Upvotes: 2

Related Questions