D
databinge
Hi,
Please redirect me if this is the wrong group to post to- but, I'm
starting a cpp project and have some questions about the capabilities
of objects. Ironically, I'm away from my computer this week, so I'm
programming by hand in a notebook. (I'm posting this from a library).
If I had my computer I'd simply try out the things I"m wondering
about- but I cant. Oh well.
So. I'm making a program to track the movements of stars. It's
basically a database program, with a simple renderer built in. I'm
planning to keep track of the stars in a list of star objects. For
each star I'll record 3 variables, like so:
Object::Star
{
int bearing(24); // list to hold a bearing reading for a given star.
One reading per hour of day
int ascension(24); // list to hold an ascension reading for a given
star. One reading per hour.
int brightness;
}
That's pretty much it. Forgive my sloppy syntax. So, in the Main()
program, I want to create a list of these objects, to keep track of a
whole group of stars. Say 256 of them. Like so:
Main()
{
Star all_stars(255); //a list holding 256 star objects
Star current; //a single star object to use in program
int hour = 18;
for (int i = 0; i<=255;i++)
{
current = all_stars(i);
Display_star(current.bearing(hour), current.ascension(hour)); //
function to render stars
}
return 0;
}
So, my question is, will my main() work? Particularly, is it valid
to assign all_stars(i) to "current"? - ( essentially, accessing
"all_stars(i).bearing(hour)" if that were valid). I apologize for the
syntax, but perhaps you can tell what I'm doing, and let me know if it
makes sense.
Thank you very much!
-Jack
Please redirect me if this is the wrong group to post to- but, I'm
starting a cpp project and have some questions about the capabilities
of objects. Ironically, I'm away from my computer this week, so I'm
programming by hand in a notebook. (I'm posting this from a library).
If I had my computer I'd simply try out the things I"m wondering
about- but I cant. Oh well.
So. I'm making a program to track the movements of stars. It's
basically a database program, with a simple renderer built in. I'm
planning to keep track of the stars in a list of star objects. For
each star I'll record 3 variables, like so:
Object::Star
{
int bearing(24); // list to hold a bearing reading for a given star.
One reading per hour of day
int ascension(24); // list to hold an ascension reading for a given
star. One reading per hour.
int brightness;
}
That's pretty much it. Forgive my sloppy syntax. So, in the Main()
program, I want to create a list of these objects, to keep track of a
whole group of stars. Say 256 of them. Like so:
Main()
{
Star all_stars(255); //a list holding 256 star objects
Star current; //a single star object to use in program
int hour = 18;
for (int i = 0; i<=255;i++)
{
current = all_stars(i);
Display_star(current.bearing(hour), current.ascension(hour)); //
function to render stars
}
return 0;
}
So, my question is, will my main() work? Particularly, is it valid
to assign all_stars(i) to "current"? - ( essentially, accessing
"all_stars(i).bearing(hour)" if that were valid). I apologize for the
syntax, but perhaps you can tell what I'm doing, and let me know if it
makes sense.
Thank you very much!
-Jack