Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im making a generic linked list. I cant figure out how to make an object of my class from main. My 3 files are main.cpp

Im making a generic linked list.

I cant figure out how to make an object of my class from main.

My 3 files are main.cpp dan.h dan.cpp

The error is: 15 6 [Error] prototype for 'void ll::insert()' does not match any in class 'll'

#include

#include

#include "dan.h"

using namespace std;

int main()

{

ll work;

work.insert(55);//THIS IS THE LINE THATS GIVING ME THE ERROR, Without this line it compiles and //runs.

}

#ifndef DAN_H

#define DAN_H

#include

#include

using namespace std;

template

struct node

{

T data;

node *next;

};

template

class ll

{

public:

ll();

void insert(T item);

void print();

private:

node head;

int len;

node cur;

};

#endif

#include

#include

#include "dan.h"

using namespace std;

template

ll::ll()

{

head=NULL;

cur=NULL;

len=0;

}

template

void ll::insert(T item)

{

node temp;

temp->data=item;

if(head==NULL)

{

head=temp;

head->next=NULL;

}

else

{

temp->next=head;

head=temp;

}

}

template

void ll::print()

{

node temp=head;

while(temp!=NULL)

{

cout<data<

temp=temp->next;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

How would you assess the value of an approach like this?

Answered: 1 week ago

Question

When would you use one approach, and when would you use another?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago