I finally thought I'd get around to trying out templates - thought I'd start with writing a class to handle automatically resizing arrays. But I keep getting the following error for the code below.
Code:
test.cpp:6: error: request for member `Add' in `test', which is of non-class type `Array<int> ()()'
My compiling instruction is
Code:
g++ *.cpp -o test.exe
array.h
Code:
#ifndef __ARRAY_CLASS__HEADER__
#define __ARRAY_CLASS__HEADER__
template <typename T>
class Array
{
public:
Array();
~Array();
void Add(T *value);
void Set(int index, T *value);
int GetCapacity();
int GetSize();
};
#endif
array.cpp
Code:
#include "array.h"
template <typename T>
Array<T>::Array()
{
}
template <typename T>
Array<T>::~Array()
{
}
template <typename T>
void Array<T>::Add(T *value)
{
}
template <typename T>
void Array<T>::Set(int index, T *value)
{
}
template <typename T>
int Array<T>::GetCapacity()
{
}
template <typename T>
int Array<T>::GetSize()
{
}
test.cpp
Code:
#include "array.h"
int main()
{
Array <int> test();
test.Add(5);
return 0;
}