I agree a DLL project is very ambitious as a learning exercise. There are all sorts of issues with testing, getting functions to export correctly etc, you don't want to be distracted with too soon!
There's a lot of things which would improve the structure of this project, but here are one or two to start with...
(1) Get rid of
extern Test testObj;
i.e. don't just remove "extern", remove the whole line.
Globals are not a good idea if you can avoid them.
You should just declare a local variable inside BoxProperties(); see (3).
(2) The definition of BoxProperties() in ExoDLL.cpp must agree with the declaration in ExoDLL.h ... you had "double A" which should be "double& A" in the .cpp file.
(3) Don't use "testobj = new Test();" - this creates a fresh object each time this function is called ... not only is this slow because you're allocating memory, you're not releasing it, so if this function gets called a lot, you might even run out of memory!!
Instead use "Test testobj;" which allocates the object on the stack and removes it automatically when the function returns.
void BoxProperties(double L, double H, double W, double& A, double& V)
{
Test testobj;
A = testobj.BoxArea(L, H, W);
V = testobj.BoxVolume(L, H, W);
}
(3) BTW, there is no need for a class like Test at all. Just pull BoxArea() and BoxVolume() out of the class and call them direct. It will be quicker as you're not constructing the Test object with each call to BoxProperties(). Eg
void BoxProperties(double L, double H, double W, double& A, double& V)
{
A = BoxArea(L, H, W);
V = BoxVolume(L, H, W);
}
(4) If you must use a class, at least make use of it.
Set up L, H, W as data members, and leave BoxArea/BoxVolume in the class. Add a constructor for Test to feed in L,H,W.
Then you don't need to pass in L,H,W to BoxArea() and BoxVolume() because they are members of the class and thus already know L,H,W.
To save space I've put the function definitions inside the class declaration.
Notice `public` & `private` keywords. `public` means visible to any user of the class. `private` means visible only within the class.
Normally you hide (i.e. make private) class data members so users of the class can only access them indirectly via methods.
class Test
{
public:
Test( double Lin, double Hin, double Win)
{
L=Lin; H=Hin; W=Win;
}
double BoxArea() { return 2 * ((L*H) + (L*W) + (H*W)); }
double BoxVolume() { return L * H * W; }
private:
double L;
double H;
double W;
};
void BoxProperties(double L, double H, double W, double& A, double& V)
{
Test testobj(L,H,W);
A = testobj.BoxArea();
V = testobj.BoxVolume();
}
P.S. When defining a class don't forget to put a semicolon after the closing curly braces. If you forget, you can get some weird looking error messages.