LNK2019 unresolved external symbol problem
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: LNK2019 unresolved external symbol problem

  1. #1
    Join Date
    Feb 2009
    Posts
    14

    [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 10:11 AM. Reason: Problem Resolved

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,131

    Re: LNK2019 unresolved external symbol problem

    create_product is defined as a member of ProductInfo, but not implemented that way.

  3. #3
    Join Date
    Feb 2009
    Posts
    14

    Re: LNK2019 unresolved external symbol problem

    Would you mind elaborating GCDEF? An example would be useful.

    Cheers,

    Dave.

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,131

    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.

  5. #5
    Join Date
    Feb 2009
    Posts
    14

    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.

  6. #6
    Join Date
    Feb 2009
    Posts
    14

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center