Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. problem in porting template class from VS6.0 to VS2008

problem in porting template class from VS6.0 to VS2008

Scheduled Pinned Locked Moved ATL / WTL / STL
helpquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hemant kulkarni
    wrote on last edited by
    #1

    I have a class which is using the float as template parameter . The code compiles correctly in VC6.0. But in VS2008 float is not allowed as template paramemter. So i am using the float pointer(please let me know if there is any alternative other than using int as data type). when I compile the code I get following errors at multiple places syntax error : missing ',' before identifier 'lowerBound' syntax error : missing ',' before identifier 'upperBound' 'tBoundedType' : too many template arguments How can fix this? what is error in this class declaration here is my float pointer class declaration #ifndef tBoundedType_h #define tBoundedType_h #define CLASSID_TBOUNDEDTYPE 27 template class tBoundedType { public: tBoundedType(); // Sets the value to lowerBound. tBoundedType(float * value); // An Ensure fails if value is not between lowerBound and upperBound. // tBoundedType & operator=(float *); // An Ensure fails if value is not between lowerBound and upperBound. static float LowerBound() { return lowerBound; } static float UpperBound() { return upperBound; } // operator type() const { return mValue; } // Stream me //virtual void PerformIO(tNSStream *); virtual long GetClassId() const { return CLASSID_TBOUNDEDTYPE; } long GetVersion() const { return 1; } protected: float mValue; }; template tBoundedType<lowerbound,>::tBoundedType() : mValue(*lowerBound) { } template tBoundedType::tBoundedType(float * newValue) : mValue(*newValue) { Ensure(mValue >= *lowerBound); Ensure(mValue <= *upperBound); } template tBoundedType & tBoundedType::operator=(type newValue) { Ensure(newValue >= lowerBound); Ensure(newValue <= upperBound); mValue = *newValue; return *this; } template void tBoundedType::PerformIO( tNSStream *stream ) { //int version = GetVersion(); //stream->DoIO( version ); //stream->DoIO( mValue ); }

    S 1 Reply Last reply
    0
    • H Hemant kulkarni

      I have a class which is using the float as template parameter . The code compiles correctly in VC6.0. But in VS2008 float is not allowed as template paramemter. So i am using the float pointer(please let me know if there is any alternative other than using int as data type). when I compile the code I get following errors at multiple places syntax error : missing ',' before identifier 'lowerBound' syntax error : missing ',' before identifier 'upperBound' 'tBoundedType' : too many template arguments How can fix this? what is error in this class declaration here is my float pointer class declaration #ifndef tBoundedType_h #define tBoundedType_h #define CLASSID_TBOUNDEDTYPE 27 template class tBoundedType { public: tBoundedType(); // Sets the value to lowerBound. tBoundedType(float * value); // An Ensure fails if value is not between lowerBound and upperBound. // tBoundedType & operator=(float *); // An Ensure fails if value is not between lowerBound and upperBound. static float LowerBound() { return lowerBound; } static float UpperBound() { return upperBound; } // operator type() const { return mValue; } // Stream me //virtual void PerformIO(tNSStream *); virtual long GetClassId() const { return CLASSID_TBOUNDEDTYPE; } long GetVersion() const { return 1; } protected: float mValue; }; template tBoundedType<lowerbound,>::tBoundedType() : mValue(*lowerBound) { } template tBoundedType::tBoundedType(float * newValue) : mValue(*newValue) { Ensure(mValue >= *lowerBound); Ensure(mValue <= *upperBound); } template tBoundedType & tBoundedType::operator=(type newValue) { Ensure(newValue >= lowerBound); Ensure(newValue <= upperBound); mValue = *newValue; return *this; } template void tBoundedType::PerformIO( tNSStream *stream ) { //int version = GetVersion(); //stream->DoIO( version ); //stream->DoIO( mValue ); }

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      When you post code, please tick the "Auto-encode HTML when pasting?" check-box. Doing that escapes the < sign, making your template code readable - which it really isn't now.

      Hemant kulkarni wrote:

      please let me know if there is any alternative other than using int as data type

      C++ templates only allow types and integral constant values as template parameters - so, no alternative, really...unless you encode the floating point values as integral values. Repost your code with the "Auto-encode HTML when pasting?" checkbox ticked and we may be able to help you with your problem.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups