I am learning C++ on the fly and am having problems with vectors so I am writing some programs that use vectors to familiarize myself with them.
I was following the advice from this post regarding printing out the value of a vector's size() call:
How can I get the size of an std::vector as an int?
My code is a simple C++ code:
#include <vector>
int main(int argc, char ** argv) {
/* create an int vector of size 10, initialized to 0 */
std::vector<int> int_list[10];
int int_list_size;
int_list_size = static_cast<int>(int_list.size()); // <-- compilation error here
} // End main()
I'm on Ubuntu 16.04 and I get this error:
"error: request for member 'size' in 'int_list', which is of non-class type 'std::vector<int> [10]'
Since the size of the vector int_list is 10, shouldn't size() return 10, which I can then cast to an int?