dave.rud...@usask.ca wrote: > Hi folks, Hi Dave. > I have a very simple set-up that is giving me grief. In one header > file, I have the following types defined: > > #include <vector> > > struct Point { > int frameNum; > float x, y, z; > }; > > > typedef std::vector< Point > Frame; > typedef std::vector< Frame > Capture; > > > Then, in another header, I want to use this type, but not actually > have to include the header (just for dependency simplification), so I > have > > class Capture; // forward declaration > class Vector; // forward declaration > > bool generateCentroid( const Capture& capture, int frameNumber, > Vector& posOut ); > > However, I get the following error when I do so: > > > points.h:14: error: conflicting declaration 'typedef class > std::vector<std::vector<Point, std::allocator<Point> >, > std::allocator<std::vector<Point, std::allocator<Point> > > > Capture' > pointutils.h:7: error: 'struct Capture' has a previous declaration as > 'struct Capture' > > I'm not sure exactly what it is complaining about, other than it maybe > doesn't like to match my forward declaration of Capture with the > typedef of a vector of a vector, or something like that. Can anyone > spot my mistake?
A typedef does not create a new type. It's basically just a new name for an existing one. 'class Capture;' declares a class that's different from 'std::vector< Frame >'. A possible way to get part of the cake and eat it is the following" #include <vector> struct Point { int frameNum; float x, y, z; }; class Capture : public std::vector< Frame > {}; This is a class that can be forward-declared by 'class Capture;' but is not an exact substitute, and sometimes clumsy to you (you'd need to re-implement all constructors for instance). Andre' _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus