I have the given template class with the following attributes/classes
template<class T1, class T2, int max>
class Collection{
T1 * _elementi1[max];
T2 * _elementi2[max];
int currently;
public:
Collection() {
for (size_t i = 0; i < max; i++) {
_elementi1[i] = nullptr;
_elementi2[i] = nullptr;
}
currently = 0;
}
~Collection() {
for (size_t i = 0; i < max; i++) {
delete _element1[i]; _element1[i] = nullptr;
delete _element2[i]; _element2[i] = nullptr;
}
}
T1 ** GetT1() { return _element1; }
T2 ** GetT2() { return _element2; }
int GetCurrent() { return currently; }
void Add(T1 t1, T2 t2) {
if (currently == max)
{
throw exception("MAX SIZE REACHED");
}
_element1[currently] = new T1(t1);
_element2[currently] = new T2(t2);
++currently;
}
friend ostream& operator<< (ostream &COUT, Collection&obj) {
for (size_t i = 0; i < obj.currently; i++)
COUT << *obj._element1[i] << " " << *obj._element2[i] << endl;
return COUT;
}
};
Max
is used to limit the capacity of the Collection(stupid I know..)The issues is that I use #include <algorithm>
that has a function called max
as well. Every time I want to use the variable Intellisense and the compiler use the function instead of the variable.How do I tell the compiler to use the variable max
and not the function?
Also before people submit code improvement and other suggestions.Its a exam example in which you are not allowed to rename/modify variables,you are only allowed to add stuff as you see fit.