using namespace std;
...
struct result_t {
// Hold one single result
string key;
vector<double> vector; // <----- denne får jeg nå feil på
};
./program.cpp:17: error: declaration of ‘std::vector<double, std::allocator<double> > result_t::vector’
/usr/include/c++/4.3/bits/stl_vector.h:176: error: changes meaning of ‘vector’ from ‘class std::vector<double, std::allocator<double> >’
/* tryit2.cpp - demonstrate compile error using g++ version 4.3
Compile and check command
$ g++-4.3 tryit2.cpp -o tryit2 ; ./tryit2 ; rm ./tryit2 # compile error
$ g++-4.2 tryit2.cpp -o tryit2 ; ./tryit2 ; rm ./tryit2 # OK
*/
using namespace std;
#include <string>
#include <iostream>
#include <vector>
struct result_t {
string key;
vector<double> vector; // this give trouble using g++-4.3
//vector<double> Vector; // OK
};
int main(int argc,char **argv)
{
result_t res;
string mykey=string("mykey");
vector<double> v;
for (unsigned int i=0;i<10;i++)
{
v.push_back(i);
}
res.key=mykey;
res.vector=v;
//res.Vector=v;
cerr<<"res.key=" << res.key << endl;
for (unsigned int i=0;i<10;i++)
{
cerr<<"res.vector[" << i << "]=" << res.vector[i] <<endl;
//cerr<<"res.Vector[" << i << "]=" << res.Vector[i] <<endl;
}
}
$ g++-4.3 tryit2.cpp -o tryit2 ; ./tryit2 ; rm ./tryit2
tryit2.cpp:15: error: declaration of ‘std::vector<double, std::allocator<double> > result_t::vector’
/usr/include/c++/4.3/bits/stl_vector.h:176: error: changes meaning of ‘vector’ from ‘class std::vector<double, std::allocator<double> >’
Returner til Utvikling i Linux
Registrerte brukere: Google [Bot]