R
Ralf Goertz
Hi,
why does the following not work:
#include <vector>
class foo
{
const size_t n;
const vector<int> &vec;
public:
foo(const std::vector<int> &v) : vec(&v),n(v.size()) {}
};
I get the following compilation error:
argument of type 'size_t (std::vector<int, std::allocator<int> >::
()const' does not match 'const size_t'
It seems as if I can't use the return value of a function as an
initializer. Why is that the case? And, more importantly, how can I
initialize foo::n with the size of v?
Ralf
why does the following not work:
#include <vector>
class foo
{
const size_t n;
const vector<int> &vec;
public:
foo(const std::vector<int> &v) : vec(&v),n(v.size()) {}
};
I get the following compilation error:
argument of type 'size_t (std::vector<int, std::allocator<int> >::
()const' does not match 'const size_t'
It seems as if I can't use the return value of a function as an
initializer. Why is that the case? And, more importantly, how can I
initialize foo::n with the size of v?
Ralf