K
key9
Hi all
when I using g++ -c to compile my code:
//root_element.hpp
#ifndef __ROOTELEMENT
#define __ROOTELEMENT
#include <string>
class RootElement{
public:
virtual
RootElement& operator<< (RootElement& Re, string& str);
};
#endif /* __ROOTELEMENT */
//root_element.cpp
//#include <string>
#include "root_element.hpp"
#include <sstream>
RootElement::
RootElement&
operator<< (RootElement& Re, string& str)
{
std::stringstream Temp;
Temp << str;
// acceptiStr(Temp.str ()); don't care this , just a NOP
return Re;
}
linux:~/rman_design/classes/test$ g++ -c root_element.cpp
root_element.hpp:14: error: a€?stringa€? has not been declared
root_element.hpp:14: error: a€?RootElement&
RootElement:perator<<(RootElement&, int&)a€? must take exactly one
argument
root_element.cpp:9: error: a€?stringa€? has not been declared
2 questions:
1. why it told me string not been declared?
2. RootElement:perator<<(RootElement&, int&) , here int& ,does g++ deal
undefined type as int?
$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with:
.../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit
--enable-clocale=gnu --enable-libstdcxx-debug --enable-java-awt=gtk-default
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --with-tune=pentium4 --enable-checking=release
i486-linux-gnu
Thread model: posix
gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
when I using g++ -c to compile my code:
//root_element.hpp
#ifndef __ROOTELEMENT
#define __ROOTELEMENT
#include <string>
class RootElement{
public:
virtual
RootElement& operator<< (RootElement& Re, string& str);
};
#endif /* __ROOTELEMENT */
//root_element.cpp
//#include <string>
#include "root_element.hpp"
#include <sstream>
RootElement::
RootElement&
operator<< (RootElement& Re, string& str)
{
std::stringstream Temp;
Temp << str;
// acceptiStr(Temp.str ()); don't care this , just a NOP
return Re;
}
linux:~/rman_design/classes/test$ g++ -c root_element.cpp
root_element.hpp:14: error: a€?stringa€? has not been declared
root_element.hpp:14: error: a€?RootElement&
RootElement:perator<<(RootElement&, int&)a€? must take exactly one
argument
root_element.cpp:9: error: a€?stringa€? has not been declared
2 questions:
1. why it told me string not been declared?
2. RootElement:perator<<(RootElement&, int&) , here int& ,does g++ deal
undefined type as int?
$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with:
.../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit
--enable-clocale=gnu --enable-libstdcxx-debug --enable-java-awt=gtk-default
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --with-tune=pentium4 --enable-checking=release
i486-linux-gnu
Thread model: posix
gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)