I have reworked my program completely and I am now getting linking error when I use the compiler.
Here is my header file:
Code:
#ifndef H_personType
#define H_personType
#include <string>
using namespace std;
class personType
{
public:
void print() const;
void setName(string first, string last);
string getFirstName() const;
string getLastName() const;
personType(string first = "", string last = "");
private:
string firstName; //variable to store the first name
string lastName; //variable to store the last name
};
#endif
Here my .cpp file:
Code:
#include <iostream>
#include <string>
using namespace std;
#include "personType.h"
void personType::print() const
{
cout << firstName << " " << lastName;
}
void personType::setName(string first, string last)
{
firstName = first;
lastName = last;
}
string personType::getFirstName() const
{
return firstName;
}
string personType::getLastName() const
{
return lastName;
}
//constructor
personType::personType(string first, string last)
{
firstName = first;
lastName = last;
}
Here are the error messages I get:
Code:
------ Build started: Project: ATest1, Configuration: Debug Win32 ------
Compiling...
ATest1.cpp
Linking...
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
Debug\ATest1.exe : fatal error LNK1120: 1 unresolved externals
ATest1 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can anyone explain to me what this means and how I can fix this please.
Thanks so much