Click here to Skip to main content
16,014,650 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to fix first four coumns of the List ctrl and all other columns to allow scrolling Pin
sureshpillai20-Feb-05 18:40
sureshpillai20-Feb-05 18:40 
GeneralPassing values of object. Getting garbage. Pin
macrophobia20-Feb-05 18:25
macrophobia20-Feb-05 18:25 
GeneralRe: Passing values of object. Getting garbage. Pin
David Nash20-Feb-05 22:02
David Nash20-Feb-05 22:02 
GeneralRe: Passing values of object. Getting garbage. Pin
macrophobia20-Feb-05 23:43
macrophobia20-Feb-05 23:43 
GeneralRe: Passing values of object. Getting garbage. Pin
David Nash21-Feb-05 3:10
David Nash21-Feb-05 3:10 
GeneralUPDATE - Passing values.Getting garbage. Pin
macrophobia21-Feb-05 2:01
macrophobia21-Feb-05 2:01 
GeneralRe: UPDATE - Passing values.Getting garbage. Pin
David Nash21-Feb-05 3:32
David Nash21-Feb-05 3:32 
GeneralRe: UPDATE - Passing values.Getting garbage. Pin
David Nash21-Feb-05 12:19
David Nash21-Feb-05 12:19 
Hi Travis,

I compiled your code, (after inventing a few missing bits) and it works fine for me. Your definition of setValues should look like this.

void Bread::setValues(double fat,double carb,int calor,double fiber)
{
	dblFat = fat;
	dblCarb = carb;
	intCalor = calor;
	dblFiber = fiber;
}


The contents of Tally.txt looks like this...
Food: White Slice<br />
Calories: 60<br />
Water (oz): 2.2<br />
Protein: 0<br />
Fat: 1.1<br />
Carbohydrates: 11.4<br />
Fiber: 0.9<br />
Vitamin A: 0<br />
Vitamin B: 0<br />
Vitamin C: 0<br />
Calcium: 0


One possible explanation for your problem....
Did you declare dblFat, dblCarb, intCalor and dblFiber as local variables inside setValues. If you did, you will be setting the values of local variables, and not member variables of Bread. The member variables of Bread would remain undefined and you would indeed get garbage if you streamed them to a file.

In any case, it is a good idea to set reasonable default values for member variables of a class in its constructor to avoid this sort of trap.

Cheers
David
GeneralRe: UPDATE - Passing values.Getting garbage. Pin
macrophobia21-Feb-05 15:44
macrophobia21-Feb-05 15:44 
GeneralRe: UPDATE - Passing values.Getting garbage. Pin
macrophobia21-Feb-05 16:25
macrophobia21-Feb-05 16:25 
GeneralRe: UPDATE - One final suggestion Pin
David Nash22-Feb-05 2:31
David Nash22-Feb-05 2:31 
GeneralInsert a dialog in MDI!! Pin
20-Feb-05 18:12
suss20-Feb-05 18:12 
GeneralRe: Insert a dialog in MDI!! Pin
Aamir Butt20-Feb-05 22:06
Aamir Butt20-Feb-05 22:06 
GeneralRe: Insert a dialog in MDI!! Pin
Maximilien21-Feb-05 0:30
Maximilien21-Feb-05 0:30 
GeneralEnabling HotKeys in an MFC based application Pin
PrashantJ20-Feb-05 17:47
PrashantJ20-Feb-05 17:47 
GeneralRe: Enabling HotKeys in an MFC based application Pin
ThatsAlok20-Feb-05 19:10
ThatsAlok20-Feb-05 19:10 
GeneralRe: Enabling HotKeys in an MFC based application Pin
22491720-Feb-05 19:37
22491720-Feb-05 19:37 
GeneralA Simple Problem Pin
SeanSheehan20-Feb-05 17:46
SeanSheehan20-Feb-05 17:46 
GeneralRe: A Simple Problem Pin
22491720-Feb-05 18:32
22491720-Feb-05 18:32 
GeneralRe: A Simple Problem Pin
SeanSheehan20-Feb-05 20:26
SeanSheehan20-Feb-05 20:26 
GeneralRe: A Simple Problem Pin
Jetli Jerry20-Feb-05 20:59
Jetli Jerry20-Feb-05 20:59 
GeneralRe: A Simple Problem Pin
SeanSheehan20-Feb-05 21:08
SeanSheehan20-Feb-05 21:08 
GeneralRe: A Simple Problem Pin
22491720-Feb-05 21:05
22491720-Feb-05 21:05 
GeneralRe: A Simple Problem Pin
SeanSheehan20-Feb-05 21:23
SeanSheehan20-Feb-05 21:23 
GeneralRe: A Simple Problem Pin
22491720-Feb-05 21:41
22491720-Feb-05 21:41 

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.