[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: about prvate field (maybe it's a bug for g++ 4.1.2)
From: |
毛建伟 |
Subject: |
Fwd: about prvate field (maybe it's a bug for g++ 4.1.2) |
Date: |
Thu, 17 Apr 2008 14:43:35 +0800 |
-----Original Message-----
From: "毛建伟" <address@hidden>
To: address@hidden
Date: Thu, 17 Apr 2008 14:35:26 +0800
Subject: about prvate field (maybe it's a bug for g++ 4.1.2)
Hi,
the value of private field is changed by operator &.
attached are source files.
/******************/
// Temp.h
/******************/
#include <string>
using std::string;
class Temp{
private:
string source;
public:
Temp();
Temp(string str);
string getSource()const;
};
/******************/
// Temp.cpp
/******************/
#include <string>
#include "Temp.h"
using std::string;
Temp::Temp(){};
Temp::Temp(string str){
source = str;
}
string Temp::getSource()const{
return source;
}
/******************/
// TempMain.cpp
/******************/
#include <string>
#include <iostream>
#include "Temp.h"
using namespace std;
int main(){
Temp temp("1111111111111111");
cout<<"BEGIN source = "<<temp.getSource()<<endl;
string* strp = &(temp.getSource());
*strp = "22222222222";
cout<<"EDN source = " <<temp.getSource()<<endl;
}
////////////////////
// out
////////////////////
BEGIN source = 1111111111111111
EDN source = 22222222222
/////////////////////////////
//g++ --version
////////////////////////////
g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Copyright (C) 2006 Free Software Foundation, Inc.
Looking forward to your reply!
source.tar
Description: Unix tar archive
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Fwd: about prvate field (maybe it's a bug for g++ 4.1.2),
毛建伟 <=