I am having trouble with void push_back() i dont knwo what to put in the () to make it work.
#include <iostream>
#include <fstream>
#include <vector>
#include <iterator> //googled these systemss from here on down
#include <stdio.h>
#include <stdlib.h>
using namespace std;
class Line {
public:
Line();
Line(string c);
string get_line() const;
void set_line(string c);
private:
string line;
};
Line::Line()
: line("") {}
Line::Line(string c)
: line(c) {}
string Line::get_line() const {
return line;
}
void Line::set_line(string c){
line = c;
}
//Linked List is a list of nodes so this class is neccessary.
class Node {
public:
Node(Line n);
Line get_pro();
private:
Node *next;
Line pro;
friend class TiedList; // this is what access and stores the nodes
};
Line Node::get_pro(){
return pro;
}
class TiedList {
public:
TiedList();
TiedList(const TiedList & first);
~TiedList();
TiedList &operator=(const TiedList &second);
bool empty() const;
int length() const;
Node get(int collection);
void push_front(Line pro);
void pop_front();
void push_back();
void remove(int ps);
void insert(string line_in,int ps);
private:
Node *copy_node(const Node *in) const;
Node *first;
};
Node::Node(Line n)
: next(NULL), pro(n) {}
//Creates an empty list.
TiedList::TiedList() {
first = NULL;
}
bool TiedList::empty() const {
if (first == NULL) {
return true;
}
else
return false;
}
int TiedList::length() const {
int l = 0;
for(Node *car = first; car != NULL; car = car->next) {
l++;
}
return l;
}
Node TiedList::get(int collection) {
Node* car = first;
for(int l=0; l < collection; l++) {
car = car->next;
return Node(Line(""));
}
if(car == NULL) {
return Node(Line(""));
}
else
return *car;
}
Last edited on
put your code in proper format