Error Code 3 When Linking to DLL versus Static LIbrary
I'm a VB developer by trade but am trying to make the move to C++.
There are still some things that mystify me. Below is a simplified
version of my code but it still produces the same result. If I run the
application with both the CStock and CTick classes included in my
assembly or compiled under a static library the application works
perfectly. If, however, I place those two classes in a DLL I get the
following error when I exit the application:
The program '[1408] MyApp.exe: Native' has exited with code 3 (0x3).
For the life of me I can't figure out why. Any clue for this newbie?
TICK.H
#ifndef TICK_H
#define TICK_H
class CTick
{
public:
CTick(void);
CTick(const CTick &Other);
~CTick(void);
CTick &operator=(const CTick &Other);
float fClose;
};
#endif
TICK.CPP
#include "Tick.h"
CTick::CTick(void) : fClose(0.0f)
{
}
CTick::CTick(const CTick &Other) : fClose(Other.fClose)
{
}
CTick::~CTick(void)
{
}
CTick &CTick::operator=(const CTick &Other)
{
fClose = Other.fClose;
return *this;
}
STOCK.H
#ifndef STOCK_H
#define STOCK_H
#include <vector>
#include <string>
#include "Tick.h"
using namespace std;
class CStock
{
public:
CStock(void);
CStock(const CStock &Other);
~CStock(void);
CStock &operator=(const CStock &Other);
vector<CTick> Quotes;
string szSymbol;
};
#endif
STOCK.CPP
#include "Stock.h"
CStock::CStock(void)
{
}
CStock::CStock(const CStock &Other)
{
szSymbol= Other.szSymbol;
Quotes = Other.Quotes;
}
CStock::~CStock(void)
{
}
CStock &CStock::operator=(const CStock &Other)
{
szSymbol = Other.szSymbol;
Quotes = Other.Quotes;
return *this;
}
MAIN.CPP
#include "Stock.h"
#include "Tick.h"
int _tmain(int argc, _TCHAR* argv[])
{
CStock myStock;
myStock.SetSymbol("ABC");
CTick myTick;
myTick.SetClose(1.0f);
myStock.Quotes.push_back(myTick);
return 0;
}