Wine class has a string class object member for label and a template Pair class object member that holds vintage years and numbers of bottles. The Pair class is described as below:
Code:
#include <iostream>
#include <string>
template <class T1, class T2>
class Pair{
private:
T1 a;
T2 b;
public:
T1 & first(); // allows reset of stored values by virtue of returning references;
T2 & second(); // allows reset of stored values by virtue of returning references;
T1 first() const { return a; } // report the stored values;
T2 second() const { return b; } // report the stored values;
Pair(const T1 & aval, const T2 & bval) : a(aval), b(bval) { }
Pair() {}
};
template<class T1, class T2>
T1 & Pair<T1,T2>::first(){
return a;
}
template<class T1, class T2>
T2 & Pair<T1,T2>::second(){
return b;
}
The Wine class declaration starts off as follows before I run into trouble:
Code:
#include<iostream>
#include<valarray>
#include<string>
#include<Pair.h>
using namespace std;
class Wine{
private:
typedef valarray<int>ArrayInt;
typedef Pair<ArrayInt,ArrayInt>PairArray;
string m_label;
PairArray m_PA;
int m_years;
public:
Wine();
Wine(string l = "No Label", int y = 0):m_label(l), m_years(y){};
Wine( int yr[], int bot[]){};
Wine(const char * l, int y, const int yr[], const int bot[]){ };
};
Problem I am having is how to pass int yr[], int bot[] to vintage years and bottles respectively. If it was:
Code:
typedef Pair<int, int> PairArray;
then
Code:
Wine (int yr, int bot):m_PA(yr, bot){};
seemed to work but I can't find a way to pass the int arrays to the template object member. Any suggestions would be most welcome. Thanks