H
hrmadhu
Hi,
I wish to declare a vector of deque of int, which I do as follows.
#include<vector>
#include<deque>
#include<iostream>
using namespace std;
int main(int argc, char* argv[])
{
int i=1;
int N=0;
while(i<=argc)
{
// parse arguments
// Most importantly extract the value of N
// as
N=atoi(argv);
i++;
}
// some stuff
//declare a vector of deque of int
// vector contains N deque<int>
// each of which are empty initially
// First attempt
vector<deque<int> > _MyVariable( N, deque<int>());
// Second Attempt
vector<deque<int> > _MyVariable2 (N, deque<int>(0));
// some more stuff
return 0;
}
The compiler cribs
"Warning: should not initialize a non-const reference with a
temporary." in the STL code which is instantiated in the lines of
interest above.
Could someone please clarify the exact effects of initializing in the
above fashion ?
which of the above two attempts should I use ? Is it better not to
initialize the deque i.e. to use
vector<deque<int> > _MyVar (N);
?
Thanks In Advance.
Best Regards,
Madhu.
I wish to declare a vector of deque of int, which I do as follows.
#include<vector>
#include<deque>
#include<iostream>
using namespace std;
int main(int argc, char* argv[])
{
int i=1;
int N=0;
while(i<=argc)
{
// parse arguments
// Most importantly extract the value of N
// as
N=atoi(argv);
i++;
}
// some stuff
//declare a vector of deque of int
// vector contains N deque<int>
// each of which are empty initially
// First attempt
vector<deque<int> > _MyVariable( N, deque<int>());
// Second Attempt
vector<deque<int> > _MyVariable2 (N, deque<int>(0));
// some more stuff
return 0;
}
The compiler cribs
"Warning: should not initialize a non-const reference with a
temporary." in the STL code which is instantiated in the lines of
interest above.
Could someone please clarify the exact effects of initializing in the
above fashion ?
which of the above two attempts should I use ? Is it better not to
initialize the deque i.e. to use
vector<deque<int> > _MyVar (N);
?
Thanks In Advance.
Best Regards,
Madhu.