Fred
2011-06-28 19:34:05 UTC
I've been searching a lot on the internet and I've found lots of bits and pieces about how to write a library but overall, I can't fully get it to work. I'd appreciate some help.
Here's what I've got so far:
// test_library.h
#pragma once
using namespace System;
namespace test_library
{
public ref class Class1
{
int adds(int, int);
int times(int, int);
};
}
// This is the main DLL file.
#include "stdafx.h"
#include "test_library.h"
namespace test_library
{
int Class1::adds (int a, int b)
{
return a + b;
}
int Class1::times (int a, int b)
{
return a * b;
}
}
Then I compile it and get a DLL file. My issue is, once I have the DLL file, I try adding it to some random new project that I create, but I can't get Visual Studio to see it. Also, I don't know if I'm supposed to have a DLL file in the end. I thought a .h file would be needed.
The other thing is, I can't work out how to create class member variables for Class1. I would like some class member variables so that I can then have my own constructor.
If someone could point me into the right direction, that'd be great.
Thanks.