Link to home
Start Free TrialLog in
Avatar of blossompark
blossomparkFlag for Ireland

asked on

Header Errors LNK2019, LNK1120 - Unresolved Externals

Hello all.

I'm trying to create a simple header and implement it in a cpp file, but I am experiencing the following error messages.

LNK2019 unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
LNK1120 1 unresolved externals

Here is the code for my header.

#include <iostream>

class Cat
{
public:
	Cat(int initialAge);
	~Cat();
	int GetAge() const { return itsAge; }
	void SetAge (int age) { itsAge = age; }
	void Meow() const { std::cout << "Meow.\n"; }
private:
	int itsAge;
};

Open in new window


Here is the code for the cpp file I am trying to compile.

#include "Cat.h"


Cat::Cat(int initialAge)
{
	itsAge = initialAge;
}

Cat::~Cat()
{
}

int main()
{
	Cat Frisky(5);
	Frisky.Meow();
	std::cout << "Frisky is a cat who is " << Frisky.GetAge() << " years old.\n";
	Frisky.Meow();
	Frisky.SetAge(7);
	std::cout << "Now Frisky is " << Frisky.GetAge() << " years old.\n";
	return 0;
}

Open in new window


Both have been copied directly from a book, and try as I might I can't see any mistakes in my transcription.

Many thanks in advance!
SOLUTION
Avatar of phoffric
phoffric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of blossompark

ASKER

Thank you all so much. I followed sarabande's advice and it's working perfectly now.