Hi,
I have searched the net, but did not find an answer to my question,
hope you can help me. In case I overlooked some obvious answer,
please flame away!
I have a class that requires an init value at creation time,
something like:
1 2 3 4 5 6 7 8 9 10
|
class Foo
{
public:
Foo(int a)
{
v=a;
}
private:
int v;
};
|
There is no creator without argument, so initialization is mandatory.
I like that.
From this class, I construct a templated compound class,
something like:
1 2 3 4 5 6 7 8 9 10 11
|
#include <array>
template<int N> class Bar
{
public:
Bar():???
{
}
private:
array<Foo,N> w;
};
|
The question marks indicate my problem.
By definition of Foo, w needs to be initialized at creation time.
The standard forbids initialization in the private: section,
and only allows initialization of the w member after Bar():.
(So the compiler kindly informs me.)
Preferrably, I would like to use an argument in the Bar creator,
like Bar(int p):???, where the int p would figure in the unknown spell,
alongside w of course.
So the question is: how to initialize w?
Many thanks in advance!