To start with, I'm running windows 8 with Code::Blocks 12.11.
My main goal is to create a class named SCREEN with a member Array[][] and have this Array being modified and sending data to nested classes 'Trim' and 'ScreenClass'.
To make my goal better understood, this could be achieved in another way: same class 'SCREEN' containing DIRECLTY all the functions contained in 'Trim' and 'ScreenClass', without these two classes ever being created.
BUT in those too classes, 'Trim' and 'ScreenArray', I will input MUCH code, MUCH functions and I don't want them to be RAW in the 'SCREEN' class as finding each function then, would be a real trouble!! (I tried commenting like
//=========================================================
or 2 times the above, or even with asterisks (*) but when a lot of functions gather it's getting baaaaad.)
To start visualizing it, I want something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
class SCREEN
{
private:
char Array[160][160];//[x],[y]
int CurrentWidth;
class ScreenClass
{
private:
void Initialize()
{
Array[x][y]=' '; //This refers to SCREEN::Array
}
public:
bool Set(int x,int y)
{
CurrentWidth=10; //This refers to SCREEN::CurrentWidth
Array[x][y]=' '; //This refers to SCREEN::Array
}
char Get(int x,int y)
{
return Array[x][y]; //This refers to SCREEN::Array
}
ScreenClass(){Initialize();}
};
ScreenClass ScreenArray;
class TrimClass
{//... Like ScreenClass. If I complete correctly ScreenClass, I will complete correctly this too
void Clean()
{
Array[1][1]=' '; //This refers to SCREEN::Array
}
};
TrimClass Trim;
// --other Functions--
public:
void Clean (char Background=' ')
{
ScreenArray.Set(x,y);
}
void CleanTrim (char Background=' ') //NOTE: Here after trim class
{
Trim.Clean(Background);
}
void CleanAll (char Background=' ')
{
CleanTrim(Background);
Clean(Background);
}
// --other Functions--
SCREEN()
{
}
};
|
Which is basiclly and my code....
I want to use it in the end like:
1 2 3 4 5 6 7 8 9
|
int main()
{
SCREEN Screen;
Screen.Clean();
//or
Screen.Trim.Clean();
}
|
So I don't want to use any kind of static data..
I keep getting this error: invalid use of non-static data member 'SCREEN::X'
where X is Array, CurrentWidth and other data of SCREEN.
I tried googling something like 'nested classses error invalid use of non-static data member' among other but wthout resault.
I know that in order to use anything from ScreenClass I have to create an Object of ScreenClass (which can obviousy be seen in my code xD), but what I also learned is that a class declared and defined within an enclosing class, is not a UNIQUE property of the enclosing-class...
Therefore Trim (of type TrimClass) and ScreenArray (of type ScreenClass) coud have been created and outside of SCREEN (altough their class was defined within SCREEN) and that is why they dont know which object of SCREEN they must use the data from.
Well I want EACH object of type 'SCREEN' to have it's VERY OWN set of 'Trim' and 'ScreenArray' objects. To give an example:
1 2 3 4
|
class AClass
{
int a;
}
|
In my exaple Each object of type AClass has it's very OWN integer 'a', therefore a coding line of a='something', would never send an error implying that 'a' doesn't know which object of AClass to edit 'a' from.... lol
Thanks in advance for any help :)