I need to know how to assign a value to a public class member.
Like here is my data structure.
class CFG_Rules {
public:
string LHS;
string RHS[500];
int ruleNumber;
};
I declared this in my main function() {
CFG_Rules myRules[1000];
}
passed it into my void function in main like this.
void printRules(CFG_Rules myRules[], token_type t) {
LHS[l] = current_token;
myRules[l].LHS = LHS[l];
cout <<"LHS "<<LHS[l]<<endl;
nTerms = current_token;
myRules[l].RHS = nTerms;
}
assigning the string value to the array LHS[l] and nTerms works, but it is not working for the data structure.
I have been working on this for hours.
I tried to print a test case and it is empty. how do I assign it a value. i tried strcpy but that gives me an array asking for char arrays. I want to use strings.
Like here is my data structure.
class CFG_Rules {
public:
string LHS;
string RHS[500];
int ruleNumber;
};
I declared this in my main function() {
CFG_Rules myRules[1000];
}
passed it into my void function in main like this.
void printRules(CFG_Rules myRules[], token_type t) {
LHS[l] = current_token;
myRules[l].LHS = LHS[l];
cout <<"LHS "<<LHS[l]<<endl;
nTerms
myRules[l].RHS
}
assigning the string value to the array LHS[l] and nTerms
I have been working on this for hours.
I tried to print a test case and it is empty. how do I assign it a value. i tried strcpy but that gives me an array asking for char arrays. I want to use strings.