Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Vector in the struct

$
0
0
Hi people,
here the following code I would like to run:
----------------------------------------------



struct students
{
std::string name;
std::vector<std::string>> friends;
}


int main
{

std::vectors<std::string> friendsdatabase; //this vector contains data imported from a csv file, 3 elements
// "John","Lucy", "bert"
struct student1;
student1.name="Anna"

//I would like to assign the elements of the vector friendsdatabase to the vector student1.friends in this way


 for (size_t m=0; m < friendsdatabase.size(); m++)
       {
        student1.friends.push_back(friendsdatabase[m]);
    }
// Here I get the the error "unable to resolve the identifier push_back
return 0;
}




Why the assigment does not work? How to assign a vector to a vector inside the struct?

Thanks for replies..

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>