Click here to Skip to main content
11,711,537 members (87,705 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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
Comments
Sergey Alexandrovich Kryukov at 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

Rate this: bad
good
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;

Cheers
Andi
  Permalink  
v2
Comments
sarapsiopao at 16-Jan-13 14:51pm
   
Ah thank you! I was thinking it was some c++ concept I have to read about :)
Sergey Alexandrovich Kryukov at 16-Jan-13 18:18pm
   
Unconfused. My 5.
—SA
Andreas Gieriet at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 529
1 OriginalGriff 200
2 Peter Leow 164
3 Abhinav S 125
4 CHill60 115
0 Maciej Los 95
1 Richard MacCutchan 90
2 Abhinav S 90
3 OriginalGriff 80
4 Member 4653839 50


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2015
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