I am working on a linked list assignment, however I am having trouble figuring out how to properly call getInsertData()
(get values from cin
and put them in a list) and getDeleteData()
(delete numbers in the list) in main()
.
The instructions say something about defining an instance variable of NumberList
, which I have already done I believe. If it's wrong, please correct me.
(There is more to this assignment, but I'm just showing the part I am having an issue with)
#include <iostream>
#include <iomanip>
#include <sstream>
#include "NumberList.h"
using namespace std;
NumberList *getInsertData(istream &, NumberList *);
NumberList *getDeleteData(istream &, NumberList *);
int main() {
// Write your code here according to the instruction . . .
int NumberList;
// Assuming a getInsertData function goes here?
cout << "Displaying list after inserting numbers" << endl;
// getInsertData
// Assuming a getDeleteData function goes here?
cout << "Displaying list after deleting numbers" << endl;
// getDeleteData
return 0;
}
My input is:
My intended output is supposed to look like this:
CodePudding user response:
You are declaring a variable named NumberList
of type int
. You need to instead declare a variable of type NumberList
.
Try something more like this:
int main() {
NumberList myList;
cout << "Displaying list after inserting numbers" << endl;
getInsertData(cin, &myList);
cout << "Displaying list after deleting numbers" << endl;
getDeleteData(cin, &myList);
return 0;
}