I am working in Visual Studio 2008 on C ++ programming assignments. We were supplied with the files that define the following namespace hierarchy (names are for this post only, I know "name space XYZ-NAMESPACE" is unnecessary):
(MAIN-NAMESPACE) (A group of functions / classes needed to implement ... (exception - NAMESPACE) {A bunch of exceptions} (numeral-NAMESPACE) {set and linkedlist class, plus herrator}}
divide between a bunch of main-NAMESPACE content files And, for some reason, I do not understand the operator & lt; Here's the problem here: I has the following data structure: it is within the MAIN-NAMESPACE Is defined in the area. When I make an example of class, and try to print a set, it tells me that: error C2679: binary '& lt; & Lt; & gt; : No operator found, which takes the operand type 'const men-NAMESPACE :: POINTER-COLLECTIONS-NAMESPACE :: set' (or no acceptable conversion) to the right hand side However, if I only Write a main () function, and set A, fill it out, and use the operator - it works What is the problem? (Note: I tried any combination of use and I think it may be included). Strange - even if the free work associated with one type in a different place name is a bad practice, but the announcement of the global namespace is always visible. The only thing I can think is that with the same name in
template & lt; typename T & gt; std :: ostream & operator & lt; (std :: ostream & os, const main-NAMESPACE :: POINTER-COLLECTIONS -NAMESPACE :: Sets
set A set B set C double digit
MAIN-NAMESPACE
, the declaration will be a shadow in the global name space - isn 'possibly In the MAIN-NAMESPACE
, there is no operator for the unrelated type & lt; & Lt; If this is the case, then you should decide that using
: operator:
& Lt; MAIN-NAMESPACE
in the declaration. Example:
Namespace A {Namespot B {Class C {}; }} Zero F (A :: B :: C *); Namespace is a {zero F (int *); Try using: f; // These two lines are zero (g) (b :: c * c; f (c);}}
Comments
Post a Comment