[RESOLVED]LNK2019 unresolved external symbol problem
Hi,
I'm new to c++ and have an issue with the LNK2019 error. I've done some googling and as of yet haven't found a solution to my problem. So here I am!!
The exact error I receive is: error LNK2019: unresolved external symbol "public: void __thiscall ProductInfo::create_product(int)" (?create_product@ProductInfo@@QAEXH@Z) referenced in function _wmain OOSD_Assignment.obj OOSD_Assignment
Essentially as soon as I add any datetypes to the function call's in the .h file it throws a wobbler, e.g. here: void create_product(int);
and the code for you:
ProductInfo.h ----->
#include "stdafx.h"
#include <iostream>
//#include <windows.h>
#include <string.h>
using namespace std;
class ProductInfo
{
public:
//std::string inp_model;
void create_product(int);
};
ProductInfo.cpp ------>
//ProductInfo.cpp - Our class that holds information about the products
#include "stdafx.h"
#include <iostream>
//#include <string.h>
using namespace std;
int price;
void create_product(int input_price) {
price = input_price;
}
Project1.cpp -------->
#include "stdafx.h"
#include "ProductInfo.h"
#include <iostream>
#include <string.h>
//int argc, _TCHAR* argv[]
using namespace std;
int _tmain()
{
//std::string xx("hello");
int xx = 100293;
ProductInfo test;
test.create_product(xx);
return 0;
}
Cheers.
Dave
Re: LNK2019 unresolved external symbol problem
create_product is defined as a member of ProductInfo, but not implemented that way.
Re: LNK2019 unresolved external symbol problem
Would you mind elaborating GCDEF? An example would be useful.
Cheers,
Dave.
Re: LNK2019 unresolved external symbol problem
This
Code:
void create_product(int input_price) {
price = input_price;
}
needs to be
Code:
void ProductInfo::create_product(int input_price) {
price = input_price;
}
to indicate that your implementation is a member of the ProductInfo class.
Re: LNK2019 unresolved external symbol problem
Ahh, that figures. I do however get a different error now:
error C2653: 'ProductInfo' : is not a class or namespace name
Any ideas on how I'd go about fixing that one?
Ta,
Dave.
Re: LNK2019 unresolved external symbol problem
never mind. I hadn't included the header file either.
Thanks for all your help.