View Single Post
  #1 (permalink)  
Old April 14th, 2006, 11:47 AM
Valke Valke is offline
Registered User
Join Date: Apr 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unresolved External Symbol - LNK2019

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:

#pragma once

class Person
    char name[30];
    int age;

#include "stdafx.h"
using namespace std;

    name = "Name";
    age = 15;

#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"


#include "stdafx.h"
using namespace std;

void main()
    Person person;

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.