Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / template issues. Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
mattn

April 01, 2005, 02:46 PM

I'm trying to create a new class from a similar one, but there is some template stuff in it that is giving me compiler errors when I try to use the same syntax as I've used for other classes.

The constructor looks like this in the .h file

  1.  
  2. // <typedef>  
  3. typedef TypedSFNode< DeformedCoordinate, IndexedFaceSet::SFCoordinate > SFDeformedCoordinate;
  4.  
  5.  
  6.  
  7. // <constructor>
  8.         DeformableMembrane(
  9. Defined< Collider, Geometry::Collider   > _collider   = 0,
  10. Defined< typename N::Renderer > _renderer             = 0,
  11. Defined< typename N::SFBound  > _bound                = 0,
  12. Defined< SFDeformedCoordinate > _deformed_coord       = 0,
  13. Defined< DeformedCoordinate   > _deformed_coord_inst  = 0,
  14. Defined< SFFloat              > _stiffness_m          = 0,
  15. Defined< SFGeometry           > _alt_haptics          = 0,
  16. Defined< SFBool               >_no_haptics            = 0,
  17. Defined< UntypedCoord         >_untyped_coord         = 0 );


The .cpp file just contains this interface, because I need to change the name.

  1. const Interface DeformableMembrane::interface
  2. (
  3.   "DeformableMembrane",
  4.   typeid( DeformableMembrane ),
  5.   Create< DeformableMembrane>::create,&DeformableMembrane::interface
  6. );


The code error i'm getting is

[C++ Error] DeformableMembrane.cpp(21): E2102 Cannot use template 'DeformableMembrane' without specifying specialization parameters

Using windows XP with Borland. Any help would be appreciated.

 
Reedbeta

April 01, 2005, 03:04 PM

Your description is pretty vague (could we see the definition of the DeformableMembrane class?), but it sounds like you may need to do this:

  1. template <typename N, typename ColliderBase>
  2. const Interface DeformableMembrane<N, ColliderBase>::interface (....);


Remember, if a class is templated, all the definitions of its members must be templated as well.

 
mattn

April 01, 2005, 03:21 PM

yeah sorry for the vagueness. Here is the declaration and some other near by stuff that maybe helps.

  1.  
  2. template< class N, class ColliderBase = typename N::Collider >
  3.   class DeformableMembrane : public N {
  4.   public:
  5.         // <typedef>
  6.         typedef TypedSFNode< DeformedCoordinate, IndexedFaceSet::SFCoordinate > SFDeformedCoordinate;
  7.  

 
vrcreator

April 06, 2005, 09:51 PM

Template is nice, but i cannot use it at will!

 
Bramz

April 07, 2005, 03:28 AM

who nice, dependent base class ... Don't forget to use this-> for any function/member of N you call/use from DeformableMembran!

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.