我有这样一段代码:
template <class T>
struct Rgb
{
T *r, *g, *b;
Rgb(int nr, int ng, int nb)
{
r = new T(nr);
g = new T(ng);
b = new T(nb);
}
Rgb(int n)
{
Rgb(n, n, n);
}
~Rgb()
{
delete r;
delete g;
delete b;
}
};
我已经这样做了,因为我希望能够创建如下对象:
Rgb<std::vector<int>> a(10); // so it creates 3 vectors inside,
// each with 10 elements or
Rgb<std::deque<double>> a(2, 5, 4); // so it creates 3 deques inside
// with different sizes
但是我上面给出的实现不起作用。请帮助我...谢谢...