Thursday, 15 September 2011

c++ - How to mitigate class declaration being far from its owner namespace declaration in a file? -


So, I have seen how useful namespace can be arranged in their respective groups to organize announcements, but now its Comes with an issue.

The difference between creating a library in C and creating a library in C ++ is in C, so you should do with them related to your announcements, for example, as a library, we dub May be a vector square in Mammoth, the name may well be MM_Vector.

In C ++, you will have a namespace mammoth that was declared as part of the vector square.

Now the difference is here in C, just by going to class announcement, how you can use it right away. In C ++, you have to find out what is the location of the name of a particular class (Actually there is only one problem in those files where the declaration is not near the location declaration, which can be normal if the constant and both Between the declared numbers). Although I like to use a namespace for the organization, in my opinion it is still valid argument as annoyance.

What have people done to reduce this mood?

MyMath.h

  Namespace Mimuth {class vector; };  

Vector.h

  # include "MyMath.h" class MyMath :: vector {public: vector (); // ...};  

Vector. CC

  #include "vector." Mimeoth :: Vector :: Vector () {/ * ... * /}  

Limiting open namespace - announcement declaration for their content declaration is complete Eligible definitions allow the compiler to capture the typo.

When applicable to your concern, class announcements and definitions in this style simplify the parent namespace of each category - what people are called


No comments:

Post a Comment