I have reproduced with a simple code below something I am missing.
Class B owns class A as member and uses same typenames .
I want to avoid replicating these templates so that in the main() I can call something like B b(a, 3.0) which would reuse template from A. Is that possible ?
#include <iostream>
#include <vector>
template<int N, typename T=double>
struct A
{
A(T val) : vecA(N, val) {}
void print() { for (auto i : vecA) std::cout << i << ";"; }
std::vector<T> vecA;
};
template<int N, typename T>
struct B
{
B(const A<N,T> & in, T scal) : a(in), scalB(scal) {}
void print() { a.print(); std::cout << " | " << scalB << std::endl; }
A<N,T> a;
T scalB;
};
int main()
{
A<5,float> a(2.0);
B<5,float> b(a, 3.0); // This is redundancy. Can I do something like B b(a,3.0) ?
b.print();
}