• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

how to fill a vector within a struct

   I am passing a vector<tag> tagList to a function that splits html tag names and their attributes.  Since there can be multiple attributes I am using a vector<string> to hold these in my 'tag' struct.  I am having trouble filling this struct's inner vector.

     In main:
         // some code
         vector<tag> tagList;
         for(vector_size k = 0; k != v.size(); ++k)
             splitWords(v[k], tagList);
     Other function:
         void splitWords(const string& s, vector<tag>& list){
                 tag record;
                 //some code to split
                 if (count == 0)
              record.name = s.substr(i, j-i);
        **             record.att.pushback(s.substr(i, j-i));

     I am getting an error on the line with the '**'.  The pushback is not working properly.  How can I fill a vector that is inside of a struct??  Thanks very much for any help ahead of time.  
1 Solution
Maybe you need to spell it with an underscore:  "push_back", as on the following line.

If that's not it, it would help if you would show the declaration of tag::att and the error message you get.
adr2002Author Commented:
Hmmm, I must have had a typo in the spelling of push_back.  Its working now.  The error message was saying that my struct was not compatible with the operator 'push_back' so I was thinking it was a compatiblility issue, but guess it was just a stupid mistake.  
    Thanks for the help.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now