-1

I am getting the errors like so

LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

LNK1120 1 unresolved externals

I am not using any strange libraries, it is very simple:

#include <iostream>
using namespace std;
class myClass {
    int* iP;
    float f = 3.0;
public:
    myClass(int i, float f_) {
        iP = new int(i);
        f = f_;
        cout << "A" << *iP * f;
    }

    myClass(int i) {
        iP = new int(i);
        cout << "B" << *iP * f;
    }

    myClass(const myClass& m) {
        iP = new int(*m.iP + 1);
        f = m.f;
        if (m) {
            cout << "C" << *iP + 1;
        }
        else {
            cout << "C" << *iP;
        }
    }
    myClass& operator=(const myClass& m) {
        if (this != &m) {
            delete iP;
            cout << "CA" << *iP * f;
        }
        return *this;
    }
    bool operator!() const {
        return f != 3.0;
    };

    operator bool() const {
        return f == 3.0;
    };
    virtual ~myClass() {
        cout << "X" << *iP;
        delete iP;
    };
    int main() {
        myClass M = 10;
        myClass N = myClass(10, 5.0);
        myClass O = myClass(M);
        return 0;
    }

};

Can someone tell me why is it doing this ?

Phong2902
  • 33
  • 2
  • 6

2 Answers2

1

I think you accidentally put the main function inside your class scope. try moving the last }; above your int main line

Pepijn Kramer
  • 9,356
  • 2
  • 8
  • 19
-2

You put your int main() function inside the class decleration.

p.s - be sure to accept this answer if it helped :D

reyalsyssup
  • 1
  • 1
  • 1