Basically, I have to make a GUI that interacts with the user and based on things like the coordinates of the points where the user clicks, stores certain values in a set of data types defined by me. The datatypes have been defined in a seperate file in c++ style, ie, using classes. However I really dont want to implement the GUI using C++. Agree or not, C++ sucks at making GUI's. I prefer using VB. So what I thought was, to make a DLL of the user defined data types and then use the dll in VB. Unfortunately I am a novice at making dll's too. I did some research on the net. But I still dont have a clue about what to do when the dll contains things like classes. So please tell me some place where I can read about dll's.
Alternatively,
I am posting my code where I have defined the data types. Someone please tell me what differences will I have to make in the code to make it build-able as a dll...
Code:
#ifndef _GRAPH_H
#define _GRAPH_H
#define INFINITE -1
class Point
{
public:
float _x, _y, _cost1, _cost2;
Point(float x, float y, float cost1 = 0, float cost2 = 0);
};
class Graph
{
Point **points;
float **adj;
int capacity;
int *free;
int freeIndex;
int _size;
public:
int size();
int insertPoint(Point *point); //returns a pointHandle
bool deletePoint(int pointHandle); //returns 0 if the pointHandle does not exist
bool editAdj(int pointHandle1, int pointHandle2, float weight); //returns INFINITE if either of pointHandle1 and pointHandle2 doesnt exist or if weight is negative
Point point(int pointHandle); //Blee
float showAdj(int pointHandle1, int pointHandle2);
bool editCost(int pointHandle, float cost1, float cost2);
Graph(int maxSize);
};
Point :: Point(float x, float y, float cost1, float cost2)
{
_x = x;
_y = y;
_cost1 = cost1;
_cost2 = cost2;
}
Graph :: Graph(int maxSize)
{
points = new Point *[maxSize];
free = new int[maxSize];
freeIndex = maxSize - 1;
adj = new float *[maxSize];
for (int i = 0; i < maxSize; i++)
{
adj[i] = new float[maxSize];
points[i] = NULL;
free[i] = maxSize - 1 - i;
}
_size = 0;
for (i = 0; i < maxSize; i++)
{
for (int j = 0; j < maxSize; j++)
{
adj[i][j] = INFINITE;
}
}
capacity = maxSize;
}
int Graph :: insertPoint(Point *point)
{
if (freeIndex < 0) return INFINITE;
int i = free[freeIndex];
freeIndex--;
points[i] = point;
_size++;
return i;
}
bool Graph :: deletePoint(int pointHandle)
{
if (points[pointHandle] == NULL) return 0;
points[pointHandle] = NULL;
freeIndex++;
free[freeIndex] = pointHandle;
_size--;
return 1;
}
bool Graph :: editAdj(int pointHandle1, int pointHandle2, float weight)
{
if (points[pointHandle1] == NULL || points[pointHandle2] == NULL || weight < 0) return 0;
adj[pointHandle1][pointHandle2] = weight;
return 1;
}
Point Graph :: point(int pointHandle)
{
Point p(0,0);
p = *points[pointHandle];
return p;
}
float Graph :: showAdj(int pointHandle1, int pointHandle2)
{
return adj[pointHandle1][pointHandle2];
}
bool Graph :: editCost(int pointHandle, float cost1, float cost2)
{
if (points[pointHandle] == NULL) return 0;
points[pointHandle] -> _cost1 = cost1;
points[pointHandle] -> _cost2 = cost2;
return 1;
}
int Graph :: size()
{
return _size;
}
#endif