I was wondering if a subclass can access variables from the main.cpp file. For example:
Main.ccp
int x = 10;
int main()
{
return 0;
}
Example Class's cpp
Subclass::Subclass ()
{
x = 5;
}
Error:
error: 'x' was not declared in this scope
I am new to coding and I was wondering if this is somehow possible, and if not, how can I do something like this?