reading data from a file - link list
i would like to write a main for my class -> my problem is that i really have no idea how to read data from a file..
this is my class file ...
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
struct node
{
string IPaddress;
int count;
node *link;
};
class IPlist
{
// contains an ordered list of IP addresses and a count of each
// occurrence
public:
IPlist(); // default constructor
// creates a new empty list
~IPlist(); // destructor - reallocates all dynamic memory of list
IPlist (const IPlist & other);
// copy constructor to create a deep copy of other IPlist
// object
bool empty() const;
// precondition : none
// postcondition : returns true if list is empty
// and otherwise false
void insertInOrder(string address);
// precondition : list is ordered and address is not in list
// postcondition : list is ordered and contains address
bool isPresent(string address) const;
// precondition : none
// postcondition : returns true if a node containing address
// is present in list and otherwise false
void updateCount(string address);
// precondition : address is in list
// postcondition : the count of node with address has been incremented
node *find (string address) const;
// precondition : none
// postcondition : returns a pointer to node containing address or
// NULL if not present
void display() const;
// precondition : none
// postcondition : the list has been displayed
// one record per line, tab-separated
// with heading IPaddress Count
private:
node *list;
};
any idea will be really appreciated