-
February 24th, 2009, 09:34 AM
#1
[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
Last edited by skycrazy123; February 24th, 2009 at 11:11 AM.
Reason: Problem Resolved
-
February 24th, 2009, 09:39 AM
#2
Re: LNK2019 unresolved external symbol problem
create_product is defined as a member of ProductInfo, but not implemented that way.
-
February 24th, 2009, 09:41 AM
#3
Re: LNK2019 unresolved external symbol problem
Would you mind elaborating GCDEF? An example would be useful.
Cheers,
Dave.
-
February 24th, 2009, 09:47 AM
#4
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.
-
February 24th, 2009, 09:54 AM
#5
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.
-
February 24th, 2009, 09:57 AM
#6
Re: LNK2019 unresolved external symbol problem
never mind. I hadn't included the header file either.
Thanks for all your help.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|