GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Feb-2009, 13:02
devilishruby devilishruby is offline
New Member
 
Join Date: Feb 2009
Posts: 17
devilishruby is an unknown quantity at this point

Using Vector Iterator


What is my mistake? When I compile this code I encountered error as displayed below

CPP / C++ / C Code:
namespace VL{
class Sift
{
struct Keypoint
  {
    int o ;    ///< Keypoint octave index

    int ix ;   ///< Keypoint integer X coordinate (unnormalized)
    int iy ;   ///< Keypoint integer Y coordinate (unnormalized)
    int is ;   ///< Keypoint integer scale indiex

    float_t x  ;  ///< Keypoint fractional X coordinate
    float_t y  ;  ///< Keypoint fractional Y coordinate
    float_t s ;   ///< Keypoint fractional scale index

    float_t sigma ;  ///< Keypoint scale
  } ; 

  typedef std::vector<Keypoint>     Keypoints ;          ///< Keypoint list datatype
  typedef Keypoints::iterator       KeypointsIter ;      ///< Keypoint list iter datatype
  typedef Keypoints::const_iterator KeypointsConstIter ; ///< Keypoint list const iter datatype
  .
  .
  }
  .
  .
  .
  }//namespace VL

CPP / C++ / C Code:
 

 myFunction()
  {
  VL::Sift::KeypointsIter VectKeypointsIter;
  
  Keypoints keypoints ;
  
  VectKeypointsIter=keypoints.begin();
  }


Code:
error C2440: '=' : cannot convert from 'struct std::pair<struct VL::Sift::Keypoint,float> *' to 'struct VL::Sift::Keypoint *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
  #2  
Old 14-Feb-2009, 08:38
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Using Vector Iterator


Quote:
Originally Posted by devilishruby
What is my mistake?
CPP / C++ / C Code:
namespace VL{
class Sift
{
  struct Keypoint
  {
  .
  .
  .
  typedef std::vector<Keypoint>     Keypoints ;          ///< Keypoint list datatype
  typedef Keypoints::iterator       KeypointsIter ;      ///< Keypoint list iter datatype
  .
  .
  .
}//namespace VL
.
.
.
 myFunction()
{
    VL::Sift::KeypointsIter VectKeypointsIter; 
    Keypoints keypoints ;
 
. 
}

...

You published enough for me to guess:
  1. KeypointsIter is defined with a typedef in the Sift class in the VL namespace.
    Since you didn't post an error message concerning VectKeypointsIter, I am assuming that the compiler recognized the typedef. (That is, I think that you are using it properly when declaring VectKeypointsIter.)

  2. Keypoints is defined with a typedef in the Sift class in the VL namespace. It appears to have the same properties as the other typedef, therefore wouldn't you use it in a like manner when declaring keypoints?
Why would you use one typedef one way and the other differently?

Regards,

Dave
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:32.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.