c++ - how to solve name collision between Type Name, Function Name and parameter name? -
for example ,i has code:
struct range { } struct fooobj { void range(int x, range** r){....} //!< ok. void foo(int x, range** r) {....} //!< not ok, why? } then fix function foo(int,range**) to:
void foo(int x, struct range** r){...} the name collision has been solved,but why function range() has no name collision?
btw, test code in vs2010.
because ::foo::range hides ::range. @ easier example:
int i; void foo() { int i; = 1; // local variable `i`. ::i = 1; // global variable `i`. } yes. q.e.d.
to use struct range, use ::range.
(and need remove void of void foo(... constructor. live example)
Comments
Post a Comment