Click here to Skip to main content
15,924,196 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Tool Tips Pin
Ravi Bhavnani12-Mar-01 14:57
professionalRavi Bhavnani12-Mar-01 14:57 
GeneralRe: Tool Tips Pin
Colin McRitchie12-Mar-01 15:18
Colin McRitchie12-Mar-01 15:18 
Generalweewew Pin
12-Mar-01 11:07
suss12-Mar-01 11:07 
GeneralRe: weewew Pin
Christian Graus12-Mar-01 12:09
protectorChristian Graus12-Mar-01 12:09 
GeneralCD-RW Pin
12-Mar-01 10:24
suss12-Mar-01 10:24 
GeneralRe: CD-RW Pin
Erik Funkenbusch12-Mar-01 10:45
Erik Funkenbusch12-Mar-01 10:45 
GeneralIIS Pin
Philip Petrescu12-Mar-01 10:20
Philip Petrescu12-Mar-01 10:20 
Questionwhat happen to my <string> please? Pin
12-Mar-01 7:22
suss12-Mar-01 7:22 
Hi,

I need a simple and small class that I can serialize to disk (using fstream in binary mode). In the class I have a Standard C++ library string member, but after pumping objects of this class to disk I lost the string value on reading back. The class is something like this;

class Person
{
public:
string sName; (private or not doesn't matter)
int nAge;
Person(const string&Name, int nAgeOfPerson);

string GetName() {return sName;};
int GetAge() {return nAge};
}
and the ctor,

Person(const string&Name, int nAgeOfPerson)
{
sName = Name; //tried both, don't work.
sName = Name.substr(); //using initializing list also not!
nAge = nAgeOfPerson;
}

For my class, sizeof tell me the object is alway and only 28 bytes, even when the name is 29 characters long. I have no problem getting the age back. I guess when I write out to the file the name characters were somehow lost. I want to use Standard C++ Lib and using string but I don't know enough Blush | :O .

If I go back the old way using a char szName[50], for example, then everything is OK. But I really don't want to assign 50 bytes for every attribute in the class (small is beautiful for me here). Can someone tell me it is possible to force a value into the string member sName?

I am not sure if I make the point clear. Thanks in advance.



Will
AnswerRe: what happen to my <string> please? Pin
Erik Funkenbusch12-Mar-01 10:54
Erik Funkenbusch12-Mar-01 10:54 
Generalproperty storage(persistance) Pin
Pankaj Mongia5-Sep-01 23:01
Pankaj Mongia5-Sep-01 23:01 
QuestionHow do you change the highlite color of a listbox? Pin
12-Mar-01 6:24
suss12-Mar-01 6:24 
AnswerTry owner draw listbox Pin
12-Mar-01 10:26
suss12-Mar-01 10:26 
AnswerRe: How do you change the highlite color of a listbox? Pin
Erik Funkenbusch12-Mar-01 10:56
Erik Funkenbusch12-Mar-01 10:56 
AnswerRe: How do you change the highlite color of a listbox? Pin
Chris Maunder12-Mar-01 12:51
cofounderChris Maunder12-Mar-01 12:51 
AnswerRe: How do you change the highlite color of a listbox? Pin
Ravi Bhavnani12-Mar-01 14:47
professionalRavi Bhavnani12-Mar-01 14:47 
GeneralCOM Pin
12-Mar-01 6:13
suss12-Mar-01 6:13 
GeneralRe: COM Pin
Erik Thompson12-Mar-01 7:00
sitebuilderErik Thompson12-Mar-01 7:00 
GeneralSizing a floating controlbar window Pin
NormDroid12-Mar-01 4:23
professionalNormDroid12-Mar-01 4:23 
GeneralRe: Sizing a floating controlbar window Pin
12-Mar-01 7:05
suss12-Mar-01 7:05 
GeneralRe: Sizing a floating controlbar window Pin
NormDroid12-Mar-01 8:51
professionalNormDroid12-Mar-01 8:51 
GeneralAVICap: Capture from camera to bitmap when preview window is hidden Pin
Yong Haur TAY12-Mar-01 3:59
Yong Haur TAY12-Mar-01 3:59 
GeneralRe: AVICap: Capture from camera to bitmap when preview window is hidden Pin
bobbies9-May-01 2:06
bobbies9-May-01 2:06 
QuestionHow I can place FileDialog in a view? Pin
vik12-Mar-01 3:17
vik12-Mar-01 3:17 
AnswerRe: How I can place FileDialog in a view? Pin
Christian Graus12-Mar-01 9:42
protectorChristian Graus12-Mar-01 9:42 
AnswerRe: How I can place FileDialog in a view? Pin
Michael Dunn12-Mar-01 14:51
sitebuilderMichael Dunn12-Mar-01 14:51 

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.