By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 819 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

Declaring variables in c++

100+
P: 105
Hi all,

I have a value calculated from a member function of a class and assigned it to variable in my project say

unsigned short int var1=a.inf( ); since inf ( ) returns unsigned short int

Now I have to use this value var1 to calculate another variable var2 which should be uint64 as I have to pass this var2 to another function.

In order to make them compatible I can typecast var1,convert into uint64 and use it, but I lose the data.Could you please suggest me if there is any way to do this without typecasting and not losing any data.

Thanks.
Mar 14 '07 #1
Share this Question
Share on Google+
3 Replies


100+
P: 1,646
Hi Perhaps you could post the code where you use a typecast and loose the data.
Mar 14 '07 #2

100+
P: 105
I am sorry I did not get you what u meant.
Mar 14 '07 #3

RedSon
Expert 5K+
P: 5,000
Hi all,

I have a value calculated from a member function of a class and assigned it to variable in my project say

unsigned short int var1=a.inf( ); since inf ( ) returns unsigned short int

Now I have to use this value var1 to calculate another variable var2 which should be uint64 as I have to pass this var2 to another function.

In order to make them compatible I can typecast var1,convert into uint64 and use it, but I lose the data.Could you please suggest me if there is any way to do this without typecasting and not losing any data.

Thanks.
You say:

In order to make them compatible I can typecast var1,convert into uint64 and use it, but I lose the data.

and willakawill says:

Perhaps you could post the code where you use a typecast and loose the data?

What part of that does not make sense?
Mar 14 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.