Equivalent of Java static class in C++???
Jul 12, 2010 at 8:54pm UTC
Hello I am quite fluent in java but am currently having issues switching over to c++.
In Java I could have something like
1 2 3 4 5 6 7 8
class myClass{
.....
static class myStaticClass{
.....
}
}
What is the equivalent of that in c++ ?
Can it be done in a similar way? Declaring a static class in .h file, then mentioning it in the .cpp file? Will that work?
Please help, really quite confused with this atm
Cheers
Jul 12, 2010 at 9:12pm UTC
Just leave out the static and make sure the nested class is public. Then you can use it outside the class, since all nested classes are static in the Java sense.
Jul 12, 2010 at 9:13pm UTC
So a nested public class in c++ is Java's answer to a static class?
Ill take your word for it but online I read some horrendous looking examples and but didnt get them either.
Topic archived. No new replies allowed.