Hello, I am working on a C++ assignment and I'm trying to create an array inside of a class. This class incorporates a linked list and the different index in that array will take on a certain value from this link list. This is my code from my class called word: class word{ public: string name; string words; int numTimes; word(int i){ words[i]; } word(string n){ numTimes=0; name=n; } word* next; word* previous; }; What I'm trying to do in my int main is print out the words using the array word(int i) parameter, below is my attempt. Will give medal.
This is my attempt: for(int i=0; i<=185; i++){ cout << words.name<<" "; i++; }
Any help would be great thank you@
for (int i=0; i<=185; i++) { cout << words[i].name; i++; }
Thank you! This was the correct way. However, it didn't work at first because I had to include other things in my class definition(making a change in my array definition and adding an empty constructor) Afterwords I added some different things in my int main() and incorporated the "[i]" you added in my code.
Join our real-time social learning platform and learn together with your friends!