|
Newbie Q: about functions in structures.....
I got a kindof stupid question....
how do you define a variable inside a structure by using a function that goes through a set of complex calculations...
this code is just fragmented but I think you get the jist of it.
When I try to compile it I get the error: integer needs to be a constant. or something like that, is there anyway to do this?
Thanx
L8R
-Nark
--------------------------Budha walks up to a hotdog vender and says:"Make me one with everything."L8R
When you do something like :
struct MyStruct array[10] = { ...Stuff... }
All that is in stuff is processed at compile time so you can only use consts.
To achieve what you want to do, you should initialize your structs at the beginnig of the program.
Note : if you use classes, you can use the constructor. Have a look at this :
[/source]
struct MyStruct array[10] = { ...Stuff... }
All that is in stuff is processed at compile time so you can only use consts.
To achieve what you want to do, you should initialize your structs at the beginnig of the program.
Note : if you use classes, you can use the constructor. Have a look at this :
|
[/source]
Thanks, but I don''t have my hands on a C++ compiler *yet*, so would this work in the same way as yours did?
how about that? BTW, the borland command line stuff is C++, correct? Thanks again!!
L8R
-Nark
|
how about that? BTW, the borland command line stuff is C++, correct? Thanks again!!
L8R
-Nark
--------------------------Budha walks up to a hotdog vender and says:"Make me one with everything."L8R
Actaully, here would be a simpler way, I think
create an instance of stat_tag instead of making a new struct called list that inherits from stat_tag. Also, I don''t think you can say "struct stat_tag list[4];" because you are trying to make a new struct called list[4], and I don''t think that works.
Also, you could do this:
to make an array of type stat_tag
Are you even trying to be intelligent?
''cuz if you are, it ain''t workin''
Down with Tiberia!
|
create an instance of stat_tag instead of making a new struct called list that inherits from stat_tag. Also, I don''t think you can say "struct stat_tag list[4];" because you are trying to make a new struct called list[4], and I don''t think that works.
Also, you could do this:
|
to make an array of type stat_tag
Are you even trying to be intelligent?
''cuz if you are, it ain''t workin''
![](http://www.aeon-software.com/misc/notiberia.gif)
![](http://www.aeon-software.com/misc/notiberia.gif)
[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]
First off "struct stat_tag list[4]" creates an array of structures using the stat_tag template. Second, the procedure that you are using set''s everything in the array of structures to a 6 sided die rolled two times, but the thing is that there are also char variables and different dice rolls that I need to perform to define other variables inside the structure. Sorry I didn''t make that clear.
L8R
-Nark
L8R
-Nark
--------------------------Budha walks up to a hotdog vender and says:"Make me one with everything."L8R
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement