Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++ 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual C++ 2005 For discussion of Visual C++ 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 14th, 2006, 11:47 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unresolved External Symbol - LNK2019

Hi,
I have just started programming with C using Visual C++. At the moment I am learning how to handle classes. I am using a C++ book, where I am instructed to create applications that use classes like this:

Person.h
#pragma once

class Person
{
private:
    char name[30];
    int age;
public:
    Person();
};


ClassPerson.h
#include "stdafx.h"
using namespace std;

Person::Person()
{
    name = "Name";
    age = 15;
}


stdafx.h
#pragma once


#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <stdio.h>
#include <tchar.h>
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include "Person.h"


Person.cpp

#include "stdafx.h"
using namespace std;

void main()
{
    Person person;
    cin.get();
}

This is not working. I get an unresolved external symbol LNK2019 error:
Person.obj : error LNK2019: unresolved external symbol "public: __thiscall Person::Person(void)" (??0Person@@QAE@XZ) referenced in function _main

I have made the example here as simple as possible. I have searched MSDN and other resources how to resolve the issue, but I don't fully understand what to do. So, can somebody please instruct what changes I should make in the code?

The only way to solve this so far, is to put ALL code in a single cpp-file. Also if I comment out the Person person; line, the application will run.
Thank you for your assistance.

Cheers!

  #2 (permalink)  
Old April 14th, 2006, 02:44 PM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem solved. ClassPerson.cpp (ClassPerson.h by mistake on text above) was not compiled.

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error lnk2019 Paula222 C++ Programming 3 February 27th, 2006 08:53 AM
error lnk2019 Paula222 Visual C++ 0 February 7th, 2006 06:03 PM
error LNK2020 unresolved token rachappa Visual C++ 1 January 12th, 2006 08:05 AM
Link Problems with"unresolved external symbols" ConstantineAugustus Visual C++ 2 November 22nd, 2005 06:34 AM
error LNK2019: unresolved external symbol tinawalt VS.NET 2002/2003 3 August 9th, 2005 07:59 AM



All times are GMT -4. The time now is 09:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.