This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++/stl bug?


Hi, 
g++3 is more standard conform. So you simply have to add a statement
like 

using namespace std;

after the include statements or use full qualification names like:
std::string, std::cout, etc.

Matthias


Am Mit, 2002-11-06 um 11.32 schrieb Kate minc:
> Hi,
>  I have a small program which reads as follows:
> 
> #include <iostream>
> #include <string>
> 
> void main() {
>  string one="one";
>  string two="two";
>  char *onepart=(char*)one.substr(1,1).data();
>  cout<<"onepart :"<<onepart<<endl;
>  char *twopart=(char *)two.substr(1,1).data();
>  cout<<"onepart :"<<onepart;  
>  cout<<"twopart :"<<twopart<<endl;
> }
> 
> with the output being:
> onepart :n
> onepart :w
> twopart :w
> 
> well the code is obvious enough to expect that
> onepart should not have changed after initialising
> twopart...but i am completely puzzled why is this
> happening?
> Is this a bug or a hidden feature?!
> Someone please suggest a way out to get char *
> pointer to a substring.
> thanks for any help
> 
> kate. 
> 
> PS: I am using g++ version 2.96. OS: Redhat 7.2
> On using g++3 it is says "string undeclared"!
> 
> 
> __________________________________________________
> Do you Yahoo!?
> HotJobs - Search new jobs daily now
> http://hotjobs.yahoo.com/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]