Click here to Skip to main content
16,016,613 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multiple Print calls from CMainFrame() Pin
Roger Allen23-May-02 2:54
Roger Allen23-May-02 2:54 
GeneralRe: Multiple Print calls from CMainFrame() Pin
dazinith23-May-02 4:01
dazinith23-May-02 4:01 
GeneralRe: Multiple Print calls from CMainFrame() Pin
Roger Allen23-May-02 4:35
Roger Allen23-May-02 4:35 
GeneralRe: Multiple Print calls from CMainFrame() Pin
dazinith23-May-02 6:13
dazinith23-May-02 6:13 
QuestionHow to add a macro to active document in MFC Pin
22-May-02 11:50
suss22-May-02 11:50 
QuestionHow to add automation methods and properties in VC++7.0 Pin
Tim Ranker22-May-02 11:46
Tim Ranker22-May-02 11:46 
AnswerRe: How to add automation methods and properties in VC++7.0 Pin
Tim Ranker22-May-02 12:48
Tim Ranker22-May-02 12:48 
Generalstd::string weird behaviour??¿?¿ Pin
Carlos Sánchez García22-May-02 10:27
Carlos Sánchez García22-May-02 10:27 
Hi,
I'm very surpised when I realized that std::string copy-costructor doesn´t create a new instance, just point to the older one

Try this code please.
You will get a memory fault error (VC6) when printing the copied string because destructor of first one has been called before

[code]

class CHexString {
private:
string m_byteStr;
public:
CHexString(const CHexString& hs) : m_byteStr(hs.m_byteStr) {}
CHexString(const char * hs) : m_byteStr(hs) {}
CHexString() {}
~CHexString( void ) { std::cout << "destroying " << m_byteStr << std::endl; }

const string getStr( void ) { return m_byteStr; }

friend std::ostream& operator<<(std::ostream os, const CHexString& hs) {
return os << hs.m_byteStr;
}
};

int main ( void ) {
CHexString hs0("JONNY");
CHexString hs1(hs0);
string hs2(hs1.getStr());
std::cout << "hs0 " << hs0 << " hs2 " << hs2 << std::endl;
//same error printing hs1 instead of hs2

return 1;
}


[/code]

Is this the normal behaviour to expect to?

Regards
Carlos.

GeneralRe: std::string weird behaviour??¿?¿ Pin
Joaquín M López Muñoz22-May-02 10:43
Joaquín M López Muñoz22-May-02 10:43 
GeneralRe: std::string weird behaviour??¿?¿ Pin
Dean Goodman22-May-02 10:57
Dean Goodman22-May-02 10:57 
GeneralRe: std::string weird behaviour??¿?¿ Pin
Carlos Sánchez García22-May-02 23:12
Carlos Sánchez García22-May-02 23:12 
GeneralTwo questions: CFileDialog & vector Pin
Dean Goodman22-May-02 9:59
Dean Goodman22-May-02 9:59 
GeneralRe: Two questions: CFileDialog & vector Pin
Chris Losinger22-May-02 10:01
professionalChris Losinger22-May-02 10:01 
GeneralRe: Two questions: CFileDialog & vector Pin
Dean Goodman22-May-02 10:32
Dean Goodman22-May-02 10:32 
GeneralRe: Two questions: CFileDialog & vector Pin
Joaquín M López Muñoz22-May-02 11:08
Joaquín M López Muñoz22-May-02 11:08 
GeneralExtended MAPI vs. Outlook Object Model Pin
22-May-02 9:22
suss22-May-02 9:22 
GeneralInserting strings Pin
Emearg22-May-02 8:58
Emearg22-May-02 8:58 
GeneralRe: Inserting strings Pin
Carlos Antollini22-May-02 9:25
Carlos Antollini22-May-02 9:25 
GeneralRe: Inserting strings Pin
Dean Goodman22-May-02 10:02
Dean Goodman22-May-02 10:02 
GeneralRe: Inserting strings Pin
Emearg23-May-02 5:41
Emearg23-May-02 5:41 
GeneralSearching for files in a specific folder and it's subfolders. Pin
redeemer22-May-02 8:58
redeemer22-May-02 8:58 
GeneralRe: Searching for files in a specific folder and it's subfolders. Pin
Chris Losinger22-May-02 9:07
professionalChris Losinger22-May-02 9:07 
GeneralRe: Searching for files in a specific folder and it's subfolders. Pin
redeemer22-May-02 9:09
redeemer22-May-02 9:09 
GeneralRe: Searching for files in a specific folder and it's subfolders. Pin
Chris Losinger22-May-02 9:12
professionalChris Losinger22-May-02 9:12 
GeneralRe: Searching for files in a specific folder and it's subfolders. Pin
Mazdak22-May-02 9:21
Mazdak22-May-02 9:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.