Click here to Skip to main content
15,891,849 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear all,
I'm new to c++ and this forum so I apologize if this question seems very simple.
I sometimes see something like this:

(1) static class myfoo : public Foo {
(2) public:
(3) myfoo ():Foo ("FooModel") {}
.
.
.
(4) } class_my_foo;

Specifically, I don't understand the "class_my_foo" part. What is it for? I'd love to read more about this but I don't even know what to search for. If someone could kindly point me to the right direction I would appreciate it.

Thanks and regards.
Posted
Comments
Sergey Alexandrovich Kryukov 16-Jan-13 18:24pm    
Simple or even very naive questions are perfectly fine. Some of them sometimes even reveal great death of the subject.

It's important to pose correct questions though. The problem of your post is one: this is not a question. Note, that this is practically important: as these days we have way too many non-questions or fully idiotic questions, your post, even if it is implicitly an actual question, can be accidentally removed, or reported for abuse, etc. You don't want it, so, a little secret is: make it in a clear question form, with '?' (not '(?)'), etc.

Now, your question is not stupid at all, because this C++ feature is slightly cryptic, as are many other. I'm voting 4 for the question, a bit in advance. Hope you will ask good question and will get good help in future.

Cheers,
—SA

1 solution

It defines a class and at the same time declares a variable of that class type.
C++
static class A {...} a;

is identical to
C++
class A {...}; static A a;


Cheers
Andi
 
Share this answer
 
v2
Comments
sarapsiopao 16-Jan-13 14:51pm    
Ah thank you! I was thinking it was some c++ concept I have to read about :)
Sergey Alexandrovich Kryukov 16-Jan-13 18:18pm    
Unconfused. My 5.
—SA
Andreas Gieriet 16-Jan-13 23:22pm    
Thanks for your 5!
Cheers
Andi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900