Error 1 error LNK2019: unresolved external symbol "public: void __thiscall Basic::Welcome(void)" (?Welcome@Basic@@QAEXXZ) referenced in function _main C:\Users\Dylan\documents\visual studio 2013\Projects\Robot Masters - Text\main.obj Robot Masters - Text
The main() calls Basic::Welcome() -- the member function Welcome() of class Basic, but no included object file or library contains implementation for the function.
Same in shorter example:
1 2 3 4 5 6 7 8 9 10 11 12 13
struct Foo {
int bar();
};
int main() {
Foo x;
int y = x.bar();
return y;
}
int bar() {
return 42;
}
There are no compiler errors. Line 7 calls member bar() of object x. Object x has type Foo, and definition of Foo on lines 1-3 declares Foo::bar(). The standalone bar() on lines 11-13 is selfconsistent too.
The linker, however, fails to connect the call on line 7 to any implementation. The problem is on line 11. The int bar() is a standalone function and has nothing to do with the member of Foo -- int Foo::bar().
Adding this will solve the problem:
1 2 3
int Foo::bar() {
return 7;
}
The standalone bar() is never called, but that is not an error.