I know why this is error in C++.
class A
{
A b;
};
int main() {}
Because the type of b is unresolved at the compile time
.
Then why is the below code correct??
class A
{
static A b;
}
int main() {}
Is the type of the variable b resolved if it is static??
And lastly to my surprise the following code was working for JAVA:
public class Main
{
Main g;
public static void main(String[] args)
{
System.out.println("hi");
}
}
Why is that so? I know about static variables that they are specific to a class and not to an instance. But that doesn't give the answer to the above question.... Please throw me some light.