My compiler doesn't support C++11.
It turns out there's no easy way to initialize the elements of a Standard Library container. For instance, if you want to initialize a vector of strings, you'd normally use a sequence of push_back()
calls like this:
// file.h
void init_input_tbl(vector<string>& tbl){
tbl.push_back("jan");
tbl.push_back("feb");
tbl.push_back("mar");
tbl.push_back("apr");
tbl.push_back("may");
tbl.push_back("jun");
tbl.push_back("jul");
tbl.push_back("aug");
tbl.push_back("sep");
tbl.push_back("oct");
tbl.push_back("nov");
tbl.push_back("dec");}
vector<string>month_input_tb
// file.cpp
main(){
init_input_tbl(month_input_tb);
//...
Q1. Is there another way to initialize containers in C++03?
In addition to that when I try to initialize, using function init_input_tbl()
inside the header file or in the global environment it displays the following error: this declaration has no storage class or type specifier
.
Q2. What method or technique there is to initialize vector month_input_tb
using init_input_tbl()
inside file.h
or in the global environment?