video linked list insert funciton

trying to create a linked list for video object to take in insert, remove, lookup, and print command. i keep getting an error in my insert function:


main.cpp:46:25: error: no matching function for call to 'Vlist::insert(Video&)'
list.insert(*video);
^
main.cpp:46:25: note: candidate is:
In file included from main.cpp:8:0:
vlist.h:17:10: note: void Vlist::insert(Video*)
void insert(Video *video);







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  Videolist.h

  5 #include <iostream>
  6 #ifndef VLIST_H
  7 #define VLIST_H
  8 #include <string>
  9 #include "video.h"
 10 
 11 using namespace std;
 12 
 13 class Vlist
 14 {
 15   public:
 16     Vlist();
 17     void insert(Video *video);
 18     void insert_end();
 19     void print();
 20 
 21 private:
 22     class Node
 23     {
 24       public:
 25         Node(Video *video, Node *next)
 26         {
 27           m_video=video; m_next=next;}
 28         Video* m_video;
 29         Node *m_next;
 30     };
 31 
 32    Node *m_head;




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

  Videolist.cpp

5 #include <iostream>
  6 #include "vlist.h"
  7 #include<string>
  8 #include "video.h"


   28 void Vlist::insert(Video *video)
 29 {
 30 
 31 if(m_head==NULL)
 32   {
 33     m_head=new Node(video, NULL);
 34   }
 35   else
 36   {
 37     Node *ptr=m_head;
 38     while(video->get_title()>ptr->m_next -> m_video-> get_title())
 39     {
 40       ptr=ptr->m_next;
 41     }
 42     ptr->m_next=new Node(*video, ptr->m_next);
 43   }
 44 
 45 
 46 }



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

main.cpp

 5 #include <iostream>
  6 #include <string>
  7 #include "video.h"
  8 #include "vlist.h"
  9 #include <stdio.h>


  string command;
 25   Vlist list;
 26   Video *video;
 27   // sort.insert(value);  
 28 
 29   while (getline(cin, command))
 30   {
 31     if(command=="insert")
 32     {
 33       getline(cin, title);
 34       getline(cin, url);
 35       getline(cin, comment);
 36       cin >> length;
 37       cin >> rating;
 38       cin.ignore();
 39 

 46       list.insert(*video);
 47       counter++;
 48     }
 49     else if(command=="remove")
 50     {
 51       getline(cin, url);
 52       getline(cin, comment);




list.insert(*video);
should be
list.insert(video);

The method takes a pointer, but you were dereferencing the pointer before passing it.
Topic archived. No new replies allowed.