J
Josemi
Hello!
I have a curious case with a class that has a static member defined in
a DLL. Let me explain:
dll.h
class __declspec (dllexport) A
{
public:static int valor;
PrintOut ()
{
TRACE1(valor);
}
}
dll.cpp
A::valor=23;
main.h
class B:A
{
}
main.cpp
A::valor;
{
A objeto;
objeto.valor = 34;
objeto.PrintOut();
}
Well, it happens that the value given in "main.cpp" objeto.valor =
34, PrintOut print 23. Can you know what is wrong? although I have
some idea, I think the problem is that I have to declare A::valor in
the two routines and well, the compiler creates two instances of
A::valor, Is it posible declare only one in dll.cpp file? or any idea
how to solve this problem. I can think of set routines that fill this
gap, but I wanted something less complicated.
Thanks in advance
your sincerely
Josemi
I have a curious case with a class that has a static member defined in
a DLL. Let me explain:
dll.h
class __declspec (dllexport) A
{
public:static int valor;
PrintOut ()
{
TRACE1(valor);
}
}
dll.cpp
A::valor=23;
main.h
class B:A
{
}
main.cpp
A::valor;
{
A objeto;
objeto.valor = 34;
objeto.PrintOut();
}
Well, it happens that the value given in "main.cpp" objeto.valor =
34, PrintOut print 23. Can you know what is wrong? although I have
some idea, I think the problem is that I have to declare A::valor in
the two routines and well, the compiler creates two instances of
A::valor, Is it posible declare only one in dll.cpp file? or any idea
how to solve this problem. I can think of set routines that fill this
gap, but I wanted something less complicated.
Thanks in advance
your sincerely
Josemi