BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wierd constructor problem. Please help!

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students)
View previous topic :: View next topic  
Author Message
Rob Rice
Guest





PostPosted: Thu Apr 19, 2007 1:01 am    Post subject: Wierd constructor problem. Please help! Reply with quote



Hello, All.

I am creating an instance of a TClassA object.

TClassA a(var1, var2, var3);

The above constructor calculates all the data members of the object 'a.'

There are six data members of TClassA, three floats and three user

defined types.

TypeA object1;
TypeB object2;
TypeC object3;
float object4;
float object5;
float object6;

The variables in the constructor, var1, var2, and var3 are used to

calculate the above data members. These data members are all private.

After I create 'a' via

TClassA a(var1, var2, var3);

I test the above six objects by doing

TypeA test1 = a.GetObject1();
TypeB test2 = a.GetObject2();
TypeC test3 = a.GetObject3();
float test4 = a.GetObject4();
float test5 = a.GetObject5();
float test6 = a.GetObject6();

and then I "watch" the above six objects, test1, test2, etc. Now I come

to the problem. All of the values are what they should be except the

float test5. If test5 should be, e.g., 4, I might see in the watch

window that test5 is 1.34432E-32. Here's the wierd part. If I watch

this variable

a.object5

it will display the correct value, 4.0. But test5 shows 1.34432E-32.

Morover, if I do this

float test7 = a.GetObject5();
float test8 = a.GetObject5();
float test9 = a.GetObject5();
float test10 = a.GetObject5();

I do not see test7 = test8 = test9 = test10. I get different values for

each of them! Also, if, when I get to

TClassA a(var1, var2, var3);

I step into this contsructor of TClassA, a.object5 is calculated

correctly and I am able to 'watch' that object5 is 4.0 (as it should be)

before I exit the constructor. But when I step to the line of code below

the declaration of 'a', I get the above described wierd behavior. Anyone

have any idea what's going on? Thanks for much for your help!

-Rob
Back to top
Chris Uzdavinis (TeamB)
Guest





PostPosted: Thu Apr 19, 2007 1:01 am    Post subject: Re: Wierd constructor problem. Please help! Reply with quote



"Rob Rice" <rrice (AT) ccchsv (DOT) com> writes:

Quote:
I step into this contsructor of TClassA, a.object5 is calculated
correctly and I am able to 'watch' that object5 is 4.0 (as it should
be) before I exit the constructor. But when I step to the line of
code below the declaration of 'a', I get the above described wierd
behavior. Anyone have any idea what's going on? Thanks for much
for your help!

It's not clear if the problem you're seeing only occurs within the
debugger, or actually exhibits itself as a bad value when running your
program resulting in some invalid calculation.

It would also be very helpful if you could reduce the program to the
smallest possible example that maintains this issue, and post that.
It should be derived from your real code, with all of the irrelevant
lines removed. Then we can talk about concrete issues, rather than
simply guessing.

--
Chris (TeamB);
Back to top
Thomas Maeder [TeamB]
Guest





PostPosted: Thu Apr 19, 2007 8:57 pm    Post subject: Re: Wierd constructor problem. Please help! Reply with quote



Please direct your browser at http://info.borland.com/newsgroups/ and
read the newsgroup guidelines. One of them asks us not to post the
same question to different newsgroups, but to pick the most
appropriate one and just post there. Thanks!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.