Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to create a void vector

I’m new to c++ and I was wondering why this part of my code was not working

void fill 2DVector (vector<int> someVec, int i)
{
    for (auto& row: someVec)
    row.fill(i) ;
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There are several problems with the code.

First there should be an underscore or some other valid character between fill and 2DVector instead of a space.

Second, row is an int which is a built in type and doesn’t have member functions(like fill).

//-------v--------------------------------------->added underscore. You can add other valid character except space
void fill_2DVector (vector<int> someVec, int i)
{
    for (auto& row: someVec)
        cout << row;  //you can print row which is an it 
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading