Why do I get that error??
I get the following error when using a vector member of type pointer
Error 4 error C2227: left of '->InitiateShutdown' must point to class/struct/union/generic type
and the code it refers to is
vector<WorkerThread *> workers;
workers.reserve(m_numThreads); // here workers is created
*
*
*
for (i = 0; i < m_numThreads; ++i)
{
workers[i]->InitiateShutdown(); // this line is errored
}
Why do I get that error? cant a left to -> be pointer??
[580 byte] By [
gizmokaka] at [2007-11-20 8:26:28]

# 1 Re: Why do I get that error??
For whatever reason, the compiler doesn't know what kind of object workers[i] is pointing to. If it is genuinely a pointer to some kind of object, you could do something like this:-
TheObjectKind* pMyObject = (TheObjectKind *)workers[i];
pMyObject->InitiateShutdown();In fact, within a loop, I usually find that kind of approach is easier to read.
John E at 2007-11-10 22:31:01 >

# 2 Re: Why do I get that error??
As you could probably see from my code , it is a pointer.
anyway this problem is solved, for some reason in VC8 as opposed to VC6
he wanted me to to assign a type to i within the loop,
I guess that's what made it not understand he has a pointer in it's hands.
I have a new problem now.
I am all new to C++ and I have problem with classes.
I am trying to create a class of my own with members taken from other
classes (not inherit). I include the needed headers in my class header but
when it comes to call the members form the included classes,
I can't get VS to open the func/member list it usually does, seemingly like
he doesn't recognize the class I am referring to.
#include "JetByteTools\Win32Tools\IOBuffer.h"
#include "JetByteTools\Win32Tools\SocketServerEx.h"
class MesMng{
public:
CIOBuffer:://cant get the choice list
private:
}
Tnx for your help.
# 3 Re: Why do I get that error??
CIOBuffer:://cant get the choice listFrom an unrelated object, CIOBuffer:: can only be used to access static members of the class. Any other members do not exist until you create an instance of the class (in other words, an object). Static members are similar to global variables They have to be defined (and intialised) somewhere - and you can only have one instance which is valid for all instances of the class (this means that if you change the value in one object, it will change the same value for all the other objects). I don't use VC8 but if you can't see a choice list, my guess is that there must be no static members to choose from.
John E at 2007-11-10 22:32:54 >
