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!