The line you pointed out: You're treating Node::item, a non-static data member, as a static member - only static data members can be qualified with the class identifier. Since Node::item is non-static, the compiler requires an object of Node (instance) to access Node::item. For example:
1 2
Node<int> New_Node_;
New_Node_.item = ...;
Edit: What were you trying to do on that line anyway? Just curious.
Before you get to the Nodes, you need to build a customer object:
1 2 3
customer newCust;
newCust.name =...
// etc
Then you need to load it into what appears to be a singly linked list. Note that you'll need to somehow keep track of these nodes outside that while() block.
According to my understanding (which is very little) In here I'm building a Node object named newnode and setting the templates to be customer , that means the content of Node class now should be
So, to instantiate a Node object, you must use this non-default constructor. This constructor expects an argument of type T (in this case, your customer class). Thus, when you create your object, you need to use something like this:
Node<customer> newnode(customerObject);
where customerObject is an already instantiated object of the customer class
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include "readfile.h"
#include "Node.h"
#include "List.h"
usingnamespace std ;
int main()
{
string name;
cout<<"Please enter name of file:";
cin>>name;
readFile(name);
}
main file , I checked the spelling and stuff , it doesn't seems like it's the spelling problem , do I need to declare a prototype in the main file if I'm calling function from other sources ? Aren't that handled by the header file ?
Okay, in readfile.h, you define class 'customer' which has a member function 'readFile(...)'. This means that only objects of type 'customer' can have readFile called on them, like:
in main, you are calling 'readFile(name)', which can't work because there is no customer object! Also, in readfile.cpp, you are trying to give an implementation for readFile(), but that is not the right way to do it. You need to qualify the function as being part of 'customer', so the definition needs to look something like:
1 2
customer customer::readFile(string name)
There are other problems...readFile is supposed to return a customer, but doesn't. I suspect readFile is NOT intended to be a member function of customer. There's no reason to copy string 'name' into a new string 'file'. You never do anything with the list of customers created in readFile.
You may be better off taking a step back and rethinking your logic.
Okay somehow I got the readfile function working , then I proceed into working the other header display function and I encounter this problem that I have no idea why it even happen
Hi guys , I'm now working on the delete record function ,
I'm facing problem again (I know , I'm stupid )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include "List.h"
#include "readfile.h"
#include "deleteRecord.h"
#include <iostream>
void deleteRecord(List<customer> *list,customer &input)
{
int record;
std::cout<<"Enter ID to be removed: "<<std::endl;
std::cin>>record;
//Node<customer> newnode(input);
list->find(input)->item.account==record;
list->remove();
}
What I understand is the list->find(input)->item.account==record;
will find the node that contains the value that is stored in record and return the node , the problem is next step , even I got the node , how do I find and put the position of the node into the remove function to let it know that I need this node to be removed ?