Avatar of blossompark
blossompark
Flag 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!
C++

Avatar of undefined
Last Comment
blossompark

8/22/2022 - Mon
SOLUTION
phoffric

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
evilrix

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
sarabande

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
blossompark

ASKER
Thank you all so much. I followed sarabande's advice and it's working perfectly now.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck