Sign in to follow this  
neob

Object Problem

Recommended Posts

neob    100
I have a member function in a class. The class is named gameLoad. In the .h file it looks like this.
int gameFunction(std::vector<unsigned char>&, unsigned long&, unsigned long&, const unsigned char*, unsigned long);
In main I try to call this function this way.
gameLoad load;

int error = load.gameFunction(image, w, h, buffer.size() ? &buffer[0] : 0, (unsigned long)buffer.size());
However this does not compile. Compiler errors are: main.obj : error LNK2028: unresolved token (0A00035F) "public: __thiscall gameLoad::gameLoad(void)" (??0gameLoad@@$$FQAE@XZ) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z) 1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall gameLoad::gameLoad(void)" (??0gameLoad@@$$FQAE@XZ) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z) How do I go about fixing this?

Share this post


Link to post
Share on other sites
jyk    2094
Can you post the file that includes the main() function in its entirety?

Also, how are you compiling the project? IDE? Command line? Is the source file containing the function in question part of the project? Are you linking everything correctly?

Share this post


Link to post
Share on other sites
JohnBolton    1372
Apparently, you declared a constructor in your gameLoad class, but you never implemented it (as far as the compiler/link can tell).

If you did implement it, then are a few possible reasons why the linker can't find it. Perhaps you forgot to put the .cpp file in the project.

Share this post


Link to post
Share on other sites
neob    100
You’re going to laugh.
I forgot to do write the constructor in the class .cpp

Ha-ha something so simple yet so important :)

Thank you both

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this