class systemcall
{
typedef struct
{
int pid;
int fptrCntr;
OpenFile openfileptrs[10];
}processTable[100];
public:
//other stuff开发者_如何学Python...
}
I have a member function
/* this function initializes the process table. */
void systemcall::initpTable()
{
int i = 0;
for ( i=0; i<100; i++ ) {
processTable[i].fptrCntr = 0;
}
}
The line processTable[i].fptrCntr = 0;
gives an error:
systemcall.cc:86: error: expected unqualified-id before '[' token
i have almost pulled all my hair out!!! Any ideas why this is happening? I even put the structure in the systemcall.cc file, but no use.
Thank you.
You don't want the typedef
before the declaration of processTable
since you are declaring an object, not a type. After defining processTable
as a type, you then proceed to use it as a member object, which confuses the compiler.
Try this:
class systemcall
{
struct ProcessTable
{
int pid;
int fptrCntr;
OpenFile openfileptrs[10];
};
ProcessTable processTable[100];
public:
//other stuff...
};
精彩评论