how to fill a vector within a struct

Posted on 2004-11-26
Last Modified: 2010-04-01
   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)
     = 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.  
Question by:adr2002
    LVL 15

    Accepted 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.

    Author Comment

    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

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
      Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now