Click here to Skip to main content
13,093,944 members (55,772 online)
Rate this:
Please Sign up or sign in to 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 16-Jan-13 8:35am
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.


1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

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

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.
Andreas Gieriet 16-Jan-13 23:22pm
Thanks for your 5!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100