How to print out the contents of a vector?

后端 未结 19 1688
旧时难觅i
旧时难觅i 2020-11-22 03:46

I want to print out the contents of a vector in C++, here is what I have:

#include 
#include 
#include 
#include         


        
19条回答
  •  天命终不由人
    2020-11-22 04:37

    This answer is based on the answer from Zorawar, but i couldn't leave a comment there.

    You can make the auto (C++11)/typedef version const by using cbegin and cend instead

    for (auto i = path.cbegin(); i != path.cend(); ++i)
        std::cout << *i << ' ';
    

提交回复
热议问题