Good afternoon,
Issue #1
I have a mysterious issue, where I can call a class I've defined without any issues, however if I try to add a parameter to the constructor, and instantiate the class with an argument, it gives two LNK2001
errors, one for the constructor and one for the destructor.
error LNK2001: unresolved external symbol "public: __thiscall socket_h::~socket_h(void)" (??1socket_h@@$$FQAE@XZ)
error LNK2001: unresolved external symbol "public: __thiscall socket_h::socket_h(char const *)" (??0socket_h@@$$FQAE@PBD@Z)
The code is as follows:
Class Header:
class socket_h{
protected:
;//...
public:
socket_h(const char*);
int receive_data(char* szBuffer);
int send_data(char* szMessage);
~socket_h(void);
};
Class Source:
class socket_h{
protected:
;//...
public:
socket_h()
{
socket_h("192.168.5.100");
}
socket_h(const char* ip_address)
{
;//...;
}
//...
~socket_h(void)
{
closesocket(sClient);
WSACleanup();
}
};
Calling Function:
private: System::Void read_socket_Click(System::Object^ sender, System::EventArgs^ e) {
socket_h accelerometer("192.168.5.100");
}
Issue #2
I have a follow up error.
I am still looking for help with the above issue, but in order to save time, I added an extra method to the class and changed my calling function to:
private: System::Void read_socket_Click(System::Object^ sender, System::EventArgs^ e) {
socket_h accelerometer();
accelerometer->setAddress("192.168.5.100", 80);
}
However, I now get the error:
error C2227: left of '->setAddress' must point to class/struct/union/generic type 1664 1
I seem to have done everything correctly, and I don't understand why this may be happening. Thank you.