Hi i have created a project using Visual Studio c++ and i am getting this error!
error LNK2020 unresolved token(06000006)HostInfo::S
etHostInfo
Data
I have a Header file named HostInfo.h i also have a cpp file named HostInfo.cpp.
in the cpp file i have included the header file like so, #include "HostInfo.h"
But it does not seem to be linking to it, i dont know why, can anyone help?
I have included the code for both header and cpp if you want to see it
Header file
#pragma once
using namespace System;
using namespace System::Diagnostics;
using namespace Microsoft::DirectX::Direct
Play;
public __gc class HostInfo
{
//public class methods and data members
public:
bool Equals(System::Object *obj);
int GetHashCode();
String* ToString();
HostInfo();
HostInfo(Guid gu, Address *addr, String *SessName);
bool SetHostInfoData(Guid gu, Address *addr, String *SessName);
System::Void SetGuid(Guid gu);
Guid GetGuid();
System::Void SetAddress(Address *addr);
Address* GetAddress();
System::Void SetSessionName(String *name);
String *GetSessionName();
private:
Guid GuidInstance;
Address *HostAddress;
String *SessionName;
};
##############
cpp file
#include "stdafx.h"
#include "HostInfo.h" // I think it does not seem to pick this up
HostInfo::HostInfo()
{
}
HostInfo::HostInfo(Guid gu, Address *addr, String *SessName)
{
this->GuidInstance = gu;
this->HostAddress = addr;
this->SessionName = SessName;
}
bool HostInfo::Equals(System::O
bject *obj)
{
HostInfo *node = dynamic_cast<HostInfo*>(ob
j);
return Guid::op_Equality(GuidInst
ance, node->GuidInstance);
}
int HostInfo::GetHashCode()
{
return this->GuidInstance.GetHash
Code();
}
String * HostInfo::ToString()
{
String *displayString;
if(this->SessionName->Leng
th==0) //check if we have a session
{
displayString ="<unnamed>";
}
else
{
displayString->Concat(this
->SessionN
ame);
displayString->Concat("(" , HostAddress->GetComponentS
tring("hos
tname"));
displayString->Concat(":" , Convert::ToString(HostAddr
ess->GetCo
mponentInt
eger("port
")), ")");
}
return displayString;
}
Start Free Trial