I need to use my class template inside one of the member functions (class methods), as shown below :
Declaration :
template <int N>
class Array
{
private :
int var[N];
public :
void increment ();
};
Definition :
template <int N>
void Array<N> :: increment ()
{
for (int i = 0; i < N; i++)
{
cout << i << endl;
}
}
Instantiation and method call in Main.cpp:
Array <5>var;
int main()
{
var.increment();
system ("pause");
}
I keep getting a linking error saying "1 unresolved externals" in Main.obj (Main.cpp). Please consider all "cout" and "using namespace std" to be already done in the background. I'm just adding the relevant code here.
My main problem is that I don't know how to use the class template parameter (N) inside one of the class's methods.
UPDATE: Sorry I'm late but I've found a solution to this. Thanks for the help all.