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, 03:41
devilishruby devilishruby is offline
New Member
 
Join Date: Feb 2009
Posts: 17
devilishruby is an unknown quantity at this point

Error C2514 error C2039


please help me to solve this problem, i really crack my head to solve it!
CPP / C++ / C Code:
.
.
.
std::auto_ptr<std::ifstream> *keypointsIn_pt ;
keypointsIn_pt = std::auto_ptr<std::ifstream>(new std::ifstream(keypointsFilename.c_str(),std::ios::binary)) ;
while( !keypointsIn_pt->eof() ) {....}
.
.
.

Code:
c:\ltilib\win\lti_sift04\sift.cpp(354) : error C2514: 'std::basic_ifstream<char,struct std::char_traits<char> >' : class has no constructors c:\ltilib\win\lti_sift04\sift.cpp(356) : error C2039: 'eof' : is not a member of 'auto_ptr<class std::basic_ifstream<char,struct std::char_traits<char> > >'
  #2  
Old 13-Feb-2009, 06:42
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,032
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: error C2514 error C2039


You declare keypointsIn_pt to be a pointer to an auto_ptr. From your sample, it seems you just want an auto_ptr.

Best regards,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #3  
Old 13-Feb-2009, 07:55
devilishruby devilishruby is offline
New Member
 
Join Date: Feb 2009
Posts: 17
devilishruby is an unknown quantity at this point

Re: error C2514 error C2039


Quote:
Originally Posted by LuciWiz
You declare keypointsIn_pt to be a pointer to an auto_ptr. From your sample, it seems you just want an auto_ptr.

Best regards,
Lucian

thanks for reply , sorry i didn't undrestand u, in fact the actual code was what i show below.
and is part of SIFT library and i use it in my function. i think i made mistake.please help me
it's urgent.

CPP / C++ / C Code:
#include<vector>
#include<math.h>
#include"sift.hpp"
#include"sift.h"
#include"sift.ipp"
#include"sift-conv.h"
#include<algorithm>
#include<iostream>
#include<memory>
#include<sstream>
#include<cassert>
.
.
.
	Sift::Keypoint* Sift::ReadKeys(FILE *fp)
	{
		Keypoints keypoints ;
		std::string keypointsFilename;
		// If a keypoint file is provided, then open it now 
		std::auto_ptr<std::ifstream> keypointsIn_pt ;
		keypointsIn_pt = std::auto_ptr<std::ifstream>
			(new std::ifstream(keypointsFilename.c_str(),std::ios::binary)) ;
		
		while( !keypointsIn_pt->eof() ) {
			VL::float_t x,y,sigma,th ;
			
			// read x, y, sigma and th from the beginning of the line 
			(*keypointsIn_pt) 
				>> x
				>> y
				>> sigma
				>> th ;
			
			// skip the rest of the line 
			(*keypointsIn_pt).ignore(numeric_limits<streamsize>::max(),'\n') ;
			
			// break the loop if end of file reached 
			if( keypointsIn_pt->eof() ) break ;
			
			//trhow an error if something wrong 
			if( ! keypointsIn_pt->good() ) 
				VL_THROW("Error reading keypoints file.") ;
			
			// compute integer components 
			VL::Sift::Keypoint key 
				= sift.getKeypoint(x,y,sigma) ;
			
			Keypoints::value_type entry ;
			entry.first  = key ;
			entry.second = th ;
			keypoints.push_back(entry) ;
		}
		return ???;
	}


and errors are :


Code:
c:\ltilib\win\lti_sift04\sift.cpp(356) : error C2514: 'std::basic_ifstream<char,struct std::char_traits<char> >' : class has no constructors c:\ltilib\win\lti_sift04\sift.cpp(358) : error C2027: use of undefined type 'basic_ifstream<char,struct std::char_traits<char> >' c:\ltilib\win\lti_sift04\sift.cpp(358) : error C2039: 'eof' : is not a member of 'auto_ptr<class std::basic_ifstream<char,struct std::char_traits<char> > >' c:\ltilib\win\lti_sift04\sift.cpp(358) : fatal error C1903: unable to recover from previous error(s); stopping compilation
  #4  
Old 13-Feb-2009, 11:35
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: error C2514 error C2039


Quote:
Originally Posted by devilishruby
...didn't undrestand...

Your original post had
CPP / C++ / C Code:
    std::auto_ptr<std::ifstream> *keypointsIn_pt ; //keypointsIn_pt is  pointer to an auto_ptr
    keypointsIn_pt = std::auto_ptr<std::ifstream>(new std::ifstream(keypointsFilename.c_str(),std::ios::binary)) ; // Error: can't assign an auto_ptr value to keypointsIn_pt


Now it has
CPP / C++ / C Code:
    std::auto_ptr<std::ifstream> keypointsIn_pt ; //keypointsIn_pt is an auto_ptr
    keypointsIn_pt = std::auto_ptr<std::ifstream>(new std::ifstream(keypointsFilename.c_str(),std::ios::binary)) ; // OK: Assign an auto_ptr value to keypointsIn_pt.

This shows the correction suggested by LuciWiz, so I can't see what you don't understand.



Anyhow...

Now you have:
Quote:
Originally Posted by devilishruby
...error...

Code:
. . . c:\ltilib\win\lti_sift04\sift.cpp(358) : error C2027: use of undefined type 'basic_ifstream<char,struct std::char_traits<char> >' . . .

What happens if you #include <fstream>?

Regards,

Dave
  #5  
Old 13-Feb-2009, 13:04
devilishruby devilishruby is offline
New Member
 
Join Date: Feb 2009
Posts: 17
devilishruby is an unknown quantity at this point

Re: Error C2514 error C2039


thank u indeed ,..but i changed my file struct and the problem solved ,.. and now there is another problem

http://www.gidforums.com/showthread.php?p=80183
 
 

Recent GIDBlogProgramming ebook direct download available 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 15:58.


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