• Advertisement

Archived

This topic is now archived and is closed to further replies.

symbolization

This topic is 5541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how do i make something symbolize like 1 through 90 i cant us 1 -> 90? or 1-90. so what can i do?

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by craphead
so what can i do?



Make your questions understandable.

Share this post


Link to post
Share on other sites
I think he means an abstract number.
Where x=1 would be True, as would x=90 and everything in between.

-[Image Sig removed by Run pending staff/mod consultation]
-ryan@lecherousjester.com

Share this post


Link to post
Share on other sites
>>I think he means an abstract number.
Where x=1 would be True, as would x=90 and everything in between.

EXACTLY !!!

Share this post


Link to post
Share on other sites
You would need a class and some overloaded operators, I think. Try to find a way around it for now.

If you really need an int to be several different numbers at once, you could try building a quantum computer.

Share this post


Link to post
Share on other sites
AFAIK, a var can''t store anything but one value at a time...
You don''t want it to be a random value in a specific range, do you??

Share this post


Link to post
Share on other sites
If you can think of a way to use such a variable that can''t be done better and simpler in another way, I''ll give you a cookie. What you''re asking can''t be done simply. Try to re-think your problem.

Share this post


Link to post
Share on other sites
Why exactly do you want to do this? There is probably a far better method for what you need.

And, as someone else mentioned, it probably wouldn''t be that difficult to create a class with that behavior, although I can''t imagine what you would need it for.

Share this post


Link to post
Share on other sites

    
class RangeNumber
{
public:
RangeNumber(int low, int high)
{
if(low > high)
throw "Error! Low bound must not be greater than high bound!";
this->low = low;
this->high = high;
}
bool operator==(int n)
{
return (n >= low && n <= high);
}
private:
int low;
int high;
};

Something like that ...

[edited by - Miserable on December 23, 2002 5:58:11 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by craphead
yes thats what i want, a=all numbers 1 to 90


If you want it to be one random number out of 1-90, you can do rand()%91

But I don''t think this is what you want to...

Share this post


Link to post
Share on other sites
What a useless class. I think it needs a = operator, and then it should be exactly what craphead wanted.

EDIT: Wait, never mind. A = operator would also be useless.

[edited by - micepick on December 23, 2002 6:04:27 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by micepick
What a useless class. I think it needs a = operator, and then it should be exactly what craphead wanted.

I never claimed it''s useful - it''s not, but I think it''s something like what the OP wanted.

How would you write an operator=()? I don''t know how it could be made to take more than one parameter.

Share this post


Link to post
Share on other sites
All these post and no one has mentioned an array? And this is the beginner forum and you guys are talking about a class with overloaded operators? Shame on you all.



int a[90],j;
for(j=0;j<90;j++) a[j]=i+1;

// you can loop thru and access all
// the elements like this:

for(j=0;j<90;j++) printf("\n %d",a[j]);



[edited by - nonnus29 on December 23, 2002 9:53:41 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by craphead
this is what i need but wont work

int y2;
y2>0 && y2<91;


Did you write it as ''if(y2>0 && y2<91);'' instead of ''if(y2>0 && y2<91)'', because that would make the if statement always appear to work, even if it shouldn''t.

Share this post


Link to post
Share on other sites
You don''t understand. He''s asking for an object that is all the values between 1 and 90:


  

range_int x;
x>0 && x<91; <---- bizarre syntax

if (x==5)
{
// this code executes

}

if (x==30)
{
// this code also executes

}



At least, that''s the impression I got.

Share this post


Link to post
Share on other sites
perhaps if we knew what the hell he wanted it for we could think of a solution...

Share this post


Link to post
Share on other sites

  • Advertisement