In such form…
#ifndef UNICODE
#define UNICODE
#endif
#include <Windows.h>
#include <iostream>
class A
{
public:
void makeFoo(TCHAR* output)
{
wcscpy(outputBuffer,TEXT("Hello world ♥"));
}
private:
static const int MAX_OUTPUT_SIZE=2000;
static TCHAR outputBuffer[MAX_OUTPUT_SIZE];
};
int main()
{
TCHAR string[255];
A example;
example.makeFoo(string);
MessageBox(0,string,0,0);
system("Pause");
return 0;
}
… we have a
linking error!
1>main.obj : error LNK2001: unresolved external symbol “private:
static wchar_t * A::outputBuffer” (?outputBuffer@A@@0PA_WA)
The linker error occurs because you have not provided a definition for the
A::outputBufferanywhere. Fix this by writing this in file scope:The value of
stringis unexpected because that buffer is uninitialized;makeFoodoes nothing with its argument, and you do not initialize the buffer manually. Therefore it can contain anything at all (“garbage”).