Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : Development : VS.NET project
New Topic New Poll Post Reply
Poster Message
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon VS.NET project (0)  
Schik, people will thank you for adding the VS.NET project files!

I\'m not too familiar with the specifics of VS.NET. What\'s the difference between

pRoomLabel->SetText(&*wstrDesc.begin());

and

pRoomLabel->SetText(wstrDesc.c_str());

And why would you prefer one over the other?

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
04-08-2003 at 08:35 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Schik
Level: Legendary Smitemaster
Avatar
Rank Points: 5381
Registered: 02-04-2003
IP: Logged
icon Re: VS.NET project (0)  
Previously, begin() and c_str() were used almost interchangably in DROD code.

begin() returns an iterator, while c_str() returns a const char* (or const WCHAR*).

In VC6, a string iterator is typedef\'d to a char* I believe. In VS.NET, the iterator is an actual templated class, and there are no automatic conversion operators defined for it, so a char* and string::iterator can\'t be used interchangably.

So, if you saw both:
pRoomLabel->SetText(&*wstrDesc.begin());
pRoomLabel->SetText(wstrDesc.c_str());
in my changes, then it\'s most likely a mistake (not a bug, more of an inconsistency).

My thought was to use c_str() if I needed a const WCHAR*, and &*begin() if I needed a WCHAR*.

Strictly speaking, we probably shouldn\'t muck around with the memory used in a WSTRING directly like this (as with &*wstrDesc.begin()), but it seems to work.

____________________________
The greatness of a nation and its moral progress can be judged by the way it treats its animals.
--Mahatma Gandhi
04-08-2003 at 09:14 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : Development : VS.NET project
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.