0

main.cpp:

#include <iostream>
#include "person.h"
using namespace std;

int main(){

Person human;

human.setName("frank");

cout << human.toString() << endl;

cout << "Name of person with get method: " << human.getName() << endl;

return 0;
}

person.h:

#ifndef PERSON_H_INCLUDED
#define PERSON_H_INCLUDED

#include <iostream>
using namespace std;

class Person
{
private:
string name;

public:
Person();
string toString();
void setName(string newName);
string getName();
};

#endif

person.cpp:

#include "person.h"

Person::Person()
{

name = "George";
}

string Person::toString()
{
return "Persons name is: " + name;
}

void Person::setName(string newName)
{

name = newName;
}

string Person::getName()
{

return name;
}

This is all my code from the program. When i run the program through visual studio code i get an error message that says: "c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status"

drescherjm
  • 10,365
  • 5
  • 44
  • 64
Benji
  • 1
  • For some reason your settings are set to build a GUI executable instead of a console one. Check your tasks.json – drescherjm Oct 04 '20 at 17:32
  • how do i check this – Benji Oct 05 '20 at 17:37
  • In Visual Studio code I expect that `tasks.json` sets up your building. Although you should read the documentation. It's very important that you understand the build process and your compiler when you choose to use VSCode. The documentation is here: [https://code.visualstudio.com/docs/cpp/config-mingw](https://code.visualstudio.com/docs/cpp/config-mingw) – drescherjm Oct 05 '20 at 17:42
  • problem sorted thank you for the help – Benji Oct 07 '20 at 22:47

0 Answers0