Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help debugging this error: In file included from main.cpp : 4 : LinkedList.h : In instantiation of void LinkedList::PrintReverse ( ) [ with T
Need help debugging this error:
In file included from main.cpp : :
LinkedList.h : In instantiation of void LinkedList::PrintReversewith T int :
main.cpp : : : required from here
LinkedList.h : : : error : ISO C forbids variable length arrayWvla
T listdatathisNodeCount;
~~~~~~~
Header file:
#include
#include
using namespace std;
template
struct Node
Node next;
T data;
;
template class LinkedList
public:
Node first;
Node last;
LinkedList
first NULL;
last NULL;
void AddHeadT data
if first NULL
Node temp new Node;
tempdata data;
tempnext NULL;
first temp;
last temp;
else
Node temp new Node;
tempdata data;
tempnext first;
first temp;
void AddTailT data
if last NULL
Node temp new Node;
tempdata data;
tempnext NULL;
first temp;
last temp;
else
Node temp new Node;
tempdata data;
tempnext NULL;
lastnext temp;
last temp;
void AddNodesHeadT data int size
for int i ; i size; i
thisAddHeaddatai;
void AddNodesTailT data int size
for int i ; i size; i
thisAddTaildatai;
int NodeCount
if first NULL
return ;
Node temp first;
int count ;
while temp last
count ;
temp tempnext;
return count;
void PrintForward
if first NULL
cout "List IS empty!!!" endl;
Node temp first;
do
cout tempdata ;
temp tempnext;
while temp last;
cout "NULL" endl;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started