- #1
needOfHelpCMath
- 72
- 0
what is wrong with my programming D: won't print out the "Print"
I want to print out "Print" with the arrow
Code Runs:
^
Code:
#include <iostream>
#include <cstdlib>
#include<string>
using namespace std;
class Node {
public:
Node();
Node* prev;
string key;
Node* next;
};
Node::Node() {
prev = 0;
next = 0;
return;
}
class LinkedList {
public:
LinkedList();
void Insert(string key);
void Print();
Node* Find(string key);
void Delete(Node* x);
Node* head;
};
LinkedList::LinkedList() {
head = 0;
return;
}
void LinkedList::Insert(string key) {
Node* n;
n = new Node;
n->key = key;
// Link new node to current head
// of list
n->next = head;
// Make head point to new node
head = n;
return;
}
void LinkedList::Print() {
Print* c;
return;
}int main () {
LinkedList l;
Node* n = 0;
string line;
while (true){
getline(cin, line);
if (line.empty()){
break;
}
l.Insert(line);
}
n = l.head(c);
while (n!=0){
cout << n->key << endl;
n = n->next;
}
return 0;
}
I want to print out "Print" with the arrow
Code Runs:
Code:
main.cpp: In member function 'void LinkedList::Print()':
main.cpp:58:14: error: 'c' was not declared in this scope
Print* c;
^
main.cpp: In function 'int main()':
main.cpp:80:15: error: 'c' was not declared in this scope
n = l.head(c);
^
main.cpp:80:16: error: expression cannot be used as a function
n = l.head(c);