LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   compile error on std::string(ptr.get()) (https://www.linuxquestions.org/questions/programming-9/compile-error-on-std-string-ptr-get-896469/)

fsshl 08-09-2011 10:27 PM

compile error on std::string(ptr.get())
 
Dear Linux c/g++ programers:

when I tried to test/compile a piece msvc++ workable code on my g++4.5.2 on
linux 2.6.38-10

I got compile errors

root@eric-laptop:/home/eric/cppcookbook/ch14# g++ Example14-8.cpp
In file included from Example14-8.cpp:9:0:
xerces_strings.hpp: In function ‘std::string toNative(const XMLCh*)’:
xerces_strings.hpp:26:34: error: expected initializer before ‘<’ token
xerces_strings.hpp:27:24: error: ‘ptr’ was not declared in this scope
-------------------------------
my xerces_strings.hpp
------------26, 27----------
Code:

    boost::scoped_array<char> ptr<xercesc::XMLString::transcode(str));
    return std::string(ptr.get());

I have a similar code with ptr, but my g++ did not complain error which is
used in XercesString(ptr.get());

looking to see experts' help and thanks a lot in advance, Eric

ta0kira 08-10-2011 07:52 AM

There's an obvious syntax error in the first line. You need to look at what the errors say, not just at the line numbers.
Kevin Barry


All times are GMT -5. The time now is 06:27 PM.