I'm working on this code for class, I am not expecting anyone to do my homework but help would be appreciated. Nodes are confusing for me and my professor did not explain well. The errors I am getting are where I declare the functions, I dont know the nodeType(?) that goes in the arguments. Hopefully that makes sense.I think I may have also need to initialize the node?

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

///employeeType struct, node struct, typedef statement go here.
struct employeeType
{
int idNum;
string firstName;
string lastName;
char gender;
double payrate;
int dependents;

};

typedef employeeType infoType;

struct nodeType
{
infoType info;
nodeType *link;

};


            // Function Prototypes
 void print(nodeType *);  // Function to print a LL
 void printOne (employeeType one);
 nodeType* linkdListCreate2 (ifstream& inFile);
 nodeType* linkdListCreate1 (ifstream& inFile);
 employeeType getOne ( ifstream& dataIn );
 int avgDependents (nodeType *list);
 int locateId(nodeType *list, int targetID);
 nodeType* deleteNode( nodeType  *first, int deleteID);

  int main ()
{
    //get our input file stream handling taken care of
        ifstream dataFile;
        dataFile.open ( "A10-input1.txt" );
        if (!dataFile)
        {  cout << "\n\n\t  INPUT FILE ERROR  \n\n";    }
    //------------------------------------------------
    ///Declare and initialize a head pointer to first node in list

    char choice ='U';
    while((choice != 'B')&&(choice !='F'))  {
        cout<<"Create list: Forwards(enter F)   Backwards(enter B)\n";
        cin >>choice;
    }
    ///Use a decision structure to create the list
    /// either forwards or backwards, according to the user input.
    if(choice == 'F' || choice == 'f')
    {
    linkdListCreate1(dataFile);
    }
    else if(choice == 'b' || choice == 'B')
    {
    linkdListCreate2(dataFile);
    }
    ///print the list of employees
    print(first);

    /// calculate the average number of dependents
    cout<<"\nAverage # dependents: ";
    avgDependents(first);


    ///use locateID function to determine target value, then deleteNode
    ///to remove the employee at that node number from the LL
    int id=0, location=0;
    cout<<"\nEnter an ID to fire someone: ";
    cin>>id;
    location = locateId(first, id);
    if(location!=0)
    {
       cout<<"\nID Number "<<id<<" was at node "<<location<<", and has been terminated.\n";

       ///terminate the employee with the target ID number, by deleting the node
    deleteNode(first, location);
       cout <<"\n\nNew list:\n";
       ///print the list of employees
       print(first);

    }
    else
        cout <"\nThat ID is not in our list.\n";


    cout <<"\n";
    return 0;
}
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=:-@
///-----------------------------------------------------------------
//Creates a linked list by adding a new last node after each call to
// the getOne function, thus inserting the nodes into the list in the
// same order as the input file - returns pointer to first node in list.
 nodeType* linkdListCreate1 (ifstream& inFile)
 {

    nodeType *first = NULL;
    nodeType *last = NULL;
    nodeType *temp = NULL;

    employeeType person;

    person = getOne(inFile);

    while(inFile)
    {
    temp = new nodeType;
    temp->info = person;
    temp->link = NULL;

    if(first == NULL)
    {
    first = temp;
    last = temp;

    }

    else
    {
    last->link = temp;
    last = temp;

    }
        person = getOne(inFile);
    }
        return first;

 }
///-----------------------------------------------------------------
//Creates a linked list by setting the first pointer to the new node
// after each call to the getOne function, thus inserting nodes into
// list in reverse order. returns pointer to first node in list.
 nodeType* linkdListCreate2 (ifstream& inFile)
 {
    nodeType *first = NULL, *temp = NULL;

    employeeType person;
    person = getOne(inFile);

    while(inFile)
    {
        temp = new nodeType;
        temp->info = person;
        temp->link = first;
        first = temp;
        person = getOne(inFile);

    }

    return first;

 }
///-----------------------------------------------------------------
//print makes a temp pointer to head of LL, and moves node
//to node displaying the values of the members of each element
  void print(nodeType *first)
   {
        nodeType *current;
        current = first;

        while(current != NULL)
        {
        printOne(current->info);
        cout<<"\n";
        current = current->link;
        }

   }
///-----------------------------------------------------------------
//the getOne function reads one line of input data from the file stream,
// and loads it into an employeeType class or struct object
// that it returns to the calling function
employeeType getOne ( ifstream& dataIn )
{
    employeeType one;

      dataIn >> one.firstName >> one.lastName >> one.gender
             >> one.idNum >> one.payrate >> one.dependents;

      return one;
 }
///-----------------------------------------------------------------
//print out one employeeType class or struct object
 void printOne ( employeeType one)
 {
      cout << fixed << showpoint << setprecision (2);
      cout << "ID Num: " << one.idNum << endl;
      cout << "Name: " <<one.firstName << " " << one.lastName<< endl;
      cout << "-Gender: " << one.gender <<"\n";
      cout << "-Payrate $"<< one.payrate <<"\n";
      cout << "-Dependents " << one.dependents <<"\n";
 }
///-----------------------------------------------------------------
// in case of duplicates, the first occurrence of deleteItem is removed.
// list can be ordered or unordered
nodeType * deleteNode(nodeType *first, int deleteID)
{
//find correct position

badOne = new nodeType;
badOne = first->info;
first->link = badOne->link;
delete badOne;

}//end deleteNode
//=======================================================================
//calculates average number of dependents for all employees
 int avgDependents (nodeType *list)
 {
    if(list == NULL)
    {
    return 0;
    }

    int sum=0, avg=0, count=0;
    nodeType *ptr;
    ptr = list;

    while( ptr != NULL)
    {
    sum = sum + ptr->info.dependents;
    count++;
    ptr = ptr->link;

    }

    if(count!= 0)
    {
    avg = sum/count;
    return avg;

    }

 }// end of average function
//=======================================================================
//=======================================================================
//locates the number of the node in the list that
//contains the target ID value.
 int locateId(nodeType *list, int targetID)
 {
    if(list == NULL)
    {
    return 0;
    }

    int count = 1;

    nodeType *ptr;
    ptr = list;

    while(ptr != NULL)
    {
    if(ptr->info.idNum == targetID)
    {
    return count;
    }
    count++;
    ptr = ptr->link;
    }

 }// end of locate the ID function
//=======================================================================
///-=-=-=-=-=-=-=-=-=-=-=-=-endOf-main=-=-=-=-=-=-=-=-=-=-=-=-=-=:-@

try

           // Function Prototypes
 void print(nodeType *nodeTypePtr);  // Function to print a LL

copy paste the error

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.