Unresolved token ERROR

J

jazihak

Can any one tell me how to resolve this issue;

I have the following function

//hello.cpp
#include "stdafx.h"
#include <stdlib.h>
#include <vcclr.h>
#include <string>
namespace Wrapper
{

String^ Wrapper_Class::sayHello(void){
String^ str="Hello";
return str;
}
}

//hello.h
#pragma once

#include "string"
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"

using namespace System::Runtime::InteropServices;
using namespace System;
using namespace std;

String^ Wrapper_Class::sayHello(void)


Here is the ERROR message I keep getting
error LNK2020: unresolved token (06000012)
Wrapper.Wrapper_Class::sayHello
fatal error LNK1120: 1 unresolved externals



Can any one tell me what am I doing wrong? or how to resolve it? Is
there any headers that I need to include?


Thank you...
JZ
 
G

Guest

hello.cpp needs to include hello.h

Of course C++ error messages make it sound complex. The language has dozens
of keywords, thousands of error messages.
 
B

Ben Voigt [C++ MVP]

Can any one tell me how to resolve this issue;

I have the following function

//hello.cpp
#include "stdafx.h"
#include <stdlib.h>
#include <vcclr.h>
#include <string>
namespace Wrapper
{

String^ Wrapper_Class::sayHello(void){
String^ str="Hello";
return str;
}
}

This definition is inside namespace Wrapper.
//hello.h
#pragma once

#include "string"
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"

using namespace System::Runtime::InteropServices;
using namespace System;
using namespace std;

String^ Wrapper_Class::sayHello(void)

This prototype is in the global namespace. Additionally, it forward
declares that a namespace (you can't prototype class members outside the
class definition) Wrapper_Class exists containing a global function
sayHello. When the linker doesn't find it, it gives the unresolved token
error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top