Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I have no knowledge of what exactly #define is, since my c++ expertise is practically non-existant. If a #define statement is made at the start of the class and not on the fly, then a property would serve your purpose (given the example you gave), if not then I can't help.
Anybody looking for a graduate programmer (Midlands, England)?
Posted

I have given the example

#define water components[5]

 

then i can initialise array :

for (int i=0;i<MAX;i++) components=x;

 

And then use it :

if (water > x) ...

And not:

if (components[5] > x) ...

Posted

Yes and as I said if water is defined at design-time then a property would suit your purpose, but not if you need to define on the fly.

 

public component water
{
    get { return components[5] }
}
// and then you can use
if(water > x) ...

Anybody looking for a graduate programmer (Midlands, England)?
Posted
The property would definately work and seems to be the closest to what you want to do. Another way of looking at it is instead of using a 5 you could make water = 5 and call the array like components[water].

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...