Static class?

Can I add 'static' before 'class' instead of adding it before each function to make them all static in this?

1
2
3
4
5
6
class Render {
 	void DrawPlayground();
	void DrawBalls();
public:
	void DrawAll();
};
Short answer, no.
Long answer, possibly.
Last edited on
Use a namespace.

Header file (.h)
1
2
3
namespace Render {
	void DrawAll();
};


Implementation file (.cpp)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// #include header file

namespace Render {

        namespace {

 	      void DrawPlayground() { /* ... */ }
	      void DrawBalls() { /* ... */ }
              
              // variables 
        }

	void DrawAll()
        {
              // ... 
              DrawPlayground() ;
             // ...
             DrawBalls() ;
             // ...
        }
};
If all methods are static then you should ask yourself why they are in a class. The only thing a class gives in this case is the scoping rules which JLBorges pointed out can be done with a namespace also.
Topic archived. No new replies allowed.