The compiler i use is Microsoft visual studio
Hello, I am attempting to become a programmer but I only have a few books of basic programming knowledge under my belt and I figured that it would be smart to code a small bit before I move on to other things.
In this code I am trying to make a digital version of mad libs. I decided to make a vector that holds vectors that hold strings. So in a sense I have a vector that holds a story and the story in turn holds sentences. Sadly when I tried to create a story (A vector within a vector) it told me that the definition for the vector (story) was "undefined". Now this may seem a bit complex (or it may not) but when I tried to reason my way though why my compiler was not recognizing the definition I found nothing.
As you can see in the code below I created a vector called "number" then I put the number 1 in the first slot. I didnt define a number 1 anywhere else in the code and the number 1 was put into slot 1 of "number" just fine. So I reasoned that it calls the declaration within the vector sort of like this.
number.push_back (int slot1 =
1)
After I reasoned this I thought that putting a vector in a vector should work the same way like this.
Stories.push_back (vector<string>
Story1)
but since 1 didnt need the
int slot1 = i guessed that I dont need
vector<string> as well but it still gives me an error in the IDE.
This may seem like a simple question but I am completely stumped and any insight on what I need to do or what I am doing wrong would be greatly appreciated. Thank you :)
1 2 3 4 5 6 7 8 9 10
|
int main()
{
vector<int> number;
number.push_back(1);
vector<vector<string>> Stories;
// ------------------------------------------- Story 1
Stories.push_back(Story1);
Story1.push_back("Once upon a time there was a ");
|