I have a code, which is an implementation of doubly linked list.
template<class T>
struct Node{
T value;
struct Node * next_;
struct Node * prev_;
};
template <class T>
class Dex
{
public:
struct Node<T> * head = (struct Node<T> *)calloc(1, sizeof(struct Node<T>));
struct Node<T> * tail = (struct Node<T> *)calloc(1, sizeof(struct Node<T>));
struct Node<T> * current = (struct Node<T> *)calloc(1, sizeof(struct Node<T>));
When I compile this, I receive the following error:
[Error] there are no arguments to 'calloc' that depend on a template parameter, so a declaration of 'calloc' must be available [-fpermissive]
I've tried malloc, new etc. But I want to stick to calloc() for this one. Any other method to allocate memory is appreciated, as long as it works and won't throw any SIGSEV.
I expect the code to compile successfully, and be able to initialize a (struct Node *) pointer without having to deal with memory problems.
Aucun commentaire:
Enregistrer un commentaire