|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Array of structs
Hi
I'm trying to use an array of structs of class AnyClass arrays: struct XElSymbol { AnyClass PlinePts[4]; AnyClass LinePts[2]; }; XElSymbol Symbols[2];//array of 2 XElSymbol structs Symbols[1].PlinePts[0].set(0,0,0);//try to access the array and I keep getting compiler errors for the last code line: error C2143: syntax error : missing ';' before '.' error C4430: missing type specifier - int assumed. Apparently the compiler sees the access to the array as a declaration of an int array by the same name (the symbol Symbols appears twice in the class explorer) and can't be persuaded otherwise. BTW, the error is not related to the class used, it occurs even if we use just int's It's probably some stupid error but can somebody help me out? Thanks alex |
|
#2
|
||||
|
||||
|
Quote:
Fore example: Code:
class AnyClass {
public:
void set(int a,int b, int c) { }
};
struct X {
AnyClass P[4];
};
X data[2];
data[1].P[2].set(1,2,3);
int main () {
return 0;
}
Produces: Quote:
But Code:
public:
void set(int a,int b, int c) { }
};
struct X {
AnyClass P[4];
};
X data[2];
int main () {
data[1].P[2].set(1,2,3);
return 0;
}
Your results may vary as you are not using g++, but my guess is that that should fix your problem.
__________________
-- I'll provide you with reference points; if they dont work, refer to something else. If you process text, this might make your life a little easier. |
|
#3
|
|||
|
|||
|
Thank you L7Sqr
It's just as you wrote: "...is probably happening outside the scope of..." Moved it to its proper place and it compiles OK. Thanks again. ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Array of structs |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|