Basic question ASP.net webservice written in c++

K

Kristof Thys

I'm creating a ASP.net webservice written in c++, so I'm posting it on
both the aspnet and vc newsgroups. I hope somebody can help me...


What I want to do seems basic c++ to me...

I create a template ASP.net webservice.
In the helloworld function, I create an instance of a wrapperclass (wich
wraps unmanaged C++), and call a function upon it, like this:

String __gc* JagaWebserviceClass::HelloWorld()
{
ManagedWrapperClass *mw;
return mw->function();
}

I include Managedwrapper.h wich contains the following:

#include "stdafx.h"
#pragma once
#include "Interface.h"
#pragma managed

__gc class ManagedWrapperClass{
private:
Interface * i;
public:
ManagedWrapperClass() {i = new Interface;}
~ManagedWrapperClass() {delete i;}
const char* function() {return i->testfunction();}
};

In interface.h, I define my class interface:

#include "stdafx.h"
class Interface{
public:
Interface() {}
~Interface() {}
char* testfunction();
};

I create (like I always do in c++) an .cpp file, with the implementation
of my testfunction
interface.cpp:

#include "stdafx.h"
#include "Interface.h"
char* Interface::testfunction()
{
return "test";
}

But this does not work. When I put the implementation of testfunction
inline in my header file. It works perfect.

Why is this?

I can't put all my implementations is my .h because in the next step, I
will include an old project, and rewriting it is not an option...

Please help?


thx,

Kristof
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top