jeudi 30 août 2018

Templating an object in main

I'm working on a project that is a templated linklist. I got all my helper functions done and templated, but what I'm struggling with is giving my object a type in my main. I'll include all the necessary parts of my program within this post and I can edit it to where my whole project is here as well.

Header:


template <class T>
struct node{
  T data;
  struct node<T> *m_next;
};

template<class T>
class linkedList{

private:
  node<T> *m_head;
  node<T> *m_tail;

public:
  linkedList();
  void insert(T);
  void deleteNode();
  void display();
  void getHead();
  void getTail();
};

Declaration of variables from main


int main() {

   int value;
   int option = 1;
   linkedList<int> object;
   int count = 0;

Sample from main


case 1:
       cout << "Enter node to be pushed: ";
       cin >> value;
       object<int>.insert(value);
       object<int>.display();
       count++;

       break;


I'm getting the error "expected expression before int"

Any help would be appreciated!!

Aucun commentaire:

Enregistrer un commentaire