So far I've read about structs, with and without pointers. My question is about a struct in combination with a class and main. What I learn from K&R and c++ sites is that a struct can't contain values. The values I want to assign to the members will be constants. In several posts I read that I should put the struct inside the class and even inside private. The setup I use was:
class C
{
struct something {const float m = 3} s;` //actually 12 members. Compiler doesn't accept values: "ISO C++ forbids initialization of member"
function foo(struct something s){ float m = s.m; <..do something..>}` //struct s actually used in several functions
};
int main(){C c;}
Then I created 2 structs, and letting the 2nd assign values to the members of the first, which I find ugly. But why did that get accepted by gcc? So how can I assign the values only once in a proper way since assigning values has to be done inside a function. BTW, I'm using Ubuntu gcc-4.6.1.
Thank you for an answer.