0

Does anyone know how to fix this error? All I have is a header file and a source file for a class.

1>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

#ifndef POINT_H
#define POINT_H

#include <iostream>

class Point {
public:
    Point();
    Point(unsigned int x, unsigned int y);
    bool operator== (const Point &other) const;

    unsigned int m_x;
    unsigned int m_y;

    friend std::ostream& operator<<(std::ostream &sout, const Point &pt);
};

#endif

AND

#include "Point.h"


Point::Point() {}  // Needed because of existence of other constructors

Point::Point(unsigned int x, unsigned int y) {
    m_x = x;
    m_y = y;
}

// Note: automatically get copy constructor

bool
Point::operator== (const Point &other) const {
    return (m_x == other.m_x && m_y == other.m_y);
}

std::ostream& operator<<(std::ostream &sout, const Point &pt) {
    sout << "(" << pt.m_x << ", " << pt.m_y << ")";
    return sout;
}
griffer98
  • 71
  • 1
  • 1
  • 5

1 Answers1

0

It seems to be a linker error, probably related to #include or conflicting definitions. Can't say much more without code.

ZeroZ30o
  • 375
  • 2
  • 18
  • I don't see any issues in the code. In fact the error message doesn't even seem to point at your "point" file. I would assume it's a problem with your IDE, you are either compiling another project or some other file that shouldn't be there is getting compiled with the rest. Should look into "MSVCRTD.lib". Could also be project settings. – ZeroZ30o Mar 30 '18 at 18:56
  • That is why I can't figure out what is wrong. And there is no other project. I made a new project and made sure all others were deleted. – griffer98 Mar 30 '18 at 19:22
  • https://stackoverflow.com/questions/6626397/error-lnk2019-unresolved-external-symbol-winmain16-referenced-in-function This might help you? – ZeroZ30o Mar 30 '18 at 19:39