Hello!!! I am a beginner to C++ and linked list and searching algorithm really made me confused. There are 26 errors (which caused by pointer ofc). Can anyone give me idea how to fix these errors???

#include<string>
#include<cstdlib>
#include<iostream>
#include<malloc.h>
#include<fstream>
#include<time.h>
#include<conio.h>

using namespace std;
#define SIZE 10

class node
{
public:
    struct nodeL
    {
        nodeL *next;
    };

    int data;
    node *link,*customer;
    string car;
    double cost;
    double millageL,millageM;
    double condition;
    int distance;
    int millage;
    node *next;
    node *head;
    char name,nationality;
    int currency,number;//number is number of car rented
    int r,f;
    char info;
    node *s;
    struct nodes *next,*tempo;

};

class DataList
{

public:
    void insertionsort()
    {
        string list;
        int notinorder,location,amount;
        char tempo;

        for(notinorder = 1; notinorder<amount;notinorder++)

        if(list[notinorder]<list[notinorder - 1])
        {
            tempo = list[notinorder];
            location = notinorder;

            do
            {
                list[location]= list[location-1];
                location--;
            }
            while(location > 0 && list[location - 1]>tempo);
                list[location]=tempo;

        }
    }

    void print_list()
    {
        char array[5];
        cout<<"Use Insertion Sorting : \n";
        int w;
        for(w=0;w<SIZE;w++)
            cout<<" "<<array[w];
        cout<<"\n";
    }
};

class Stack
{
    node *top;
     int k;

public:
    Stack()
    {
        top=NULL;
    }

    bool isEmpty() const
    {
        return(top==NULL);
    }
    bool isFull() const
    {
        return false;
    }
    void initializeStack()
    {
        node *b;
        while(top!=NULL)
        {
            b= top;
            top = top->link;
            delete b;//deallocate memory
        }
    }
    void push(int D1)
    {
        node *t;
        t=new node;
        t->info=D1;
        t->link=top;
        top=t;
    }
    void pop()
    {
        node *t;

        if(top!=NULL)
        {
            cout<<"Stack is underflow";
            t=top;
            top = top->link;
            delete t;
        }
        else
        {
            cout<<"Stack is empty! Cannot remove element.\n";
        }
    }
    void display()
    {
        node *t=top;
        while(t!=NULL)
        {
            cout<<t->r<<"\n";
            t=t->next;
        }
    }
    int empty()
    {
        if(top==NULL)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
};

class customer
{
private:
    int calculate;


public:
    int nationality()
    {
        cout<<" Nationality ; \n Malaysia \n  Brunei Darussalam \n  Australia \n  Bangladesh \n  Others \n";
        cout<<" Please enter your nationality : \n";
        cin>>nationality;
    }
    int nationality_currency()
    {
        int currency=1;
        double malaysia=1;
        double brunei_darussala=2.30;
        double australia=2;
        double bangladesh=3;
        double others=4;

        cout<<"The currency is"<<currency;

    }
};
class Vehicle
 {
 public:

     string car;
     double cost;
     double millageL, millageM;
     double condition;
 };

 class TypeOfVehicle : public Vehicle
 {
         void test();
 }
 microcar[SIZE], saloon[SIZE], multipurpose[SIZE], motorcycle[SIZE];
 void TypeOfVehicle::test()
{

     microcar[0].car = "BMW 600";
     microcar[0].cost = 80.00;

      //microcar[0].millageL = 86.00;
      //microcar[0].millageM = 120.00;


     saloon[0].car = "AUDI A6";
     saloon[0].cost = 120.00;
     saloon[0].millageL = 144.00;
     saloon[0].millageM = 180.00;


     multipurpose[0].car = "ALZA";
     multipurpose[0].cost = 180.00;
     multipurpose[0].millageL = 216.00;
     multipurpose[0].millageM = 270.00;


     motorcycle[0].car = "YAMAHA RXZ";
     motorcycle[0].cost = 20.00;
     motorcycle[0].millageL = 24.00;
     motorcycle[0].millageM = 30.00;
     }

 class rent
 {
 private:
     char car;
     int millage;


 public:
     rent()
     {
         car;
         millage = 0;

     }
     rent(char c, int m, int p)
     {
         car = c;
         millage = m;

     }
     void setData(char c, int m)
     {
         car = c;
         millage = m;

     }
     void getData()
     {
         cout<<"Car type"<<car<<endl;
         cout<<"Milleage"<<millage<<endl;

     }
     void price()
     {
         int choice;

         cout<<"Total price : "<<millage;
     }
 };

 class listing
 {

 private :
     node *first;

 public : 
     listing()
     {
     node *first;
     first = NULL;
     }
     ~listing()
     {
         node *next;
         node *first;

        while(first)
        {
            next = first->link;
            delete first;
            first= next;
        }
     }
     void menuFirst();
     int menuNext();
     void createList();
     void deletion();
     void insertion();
     void editList();
     void search();
     void calculate();
     void rental_receipt();
     void rental_report();
     void display();
     void exit();
 };


 void listing::menuFirst()
 {
     int k = 1;
     cout << "\n--------------------------------------------------------------------------------\n";
    cout << "\t\t    WELCOME TO KENYALANG CAR RENTAL CENTRE!!\n";
    cout << "\n--------------------------------------------------------------------------------\n";
    cout << "\n\t\t\t\tTHE VEHICLES\n";
    cout << "\n--------------------------------------------------------------------------------\n";
    cout << "\n\tGROUP\tTYPE\t\tPRICE(RM)\tTYPE\n";
    cout << "\n--------------------------------------------------------------------------------\n";
    cout << " \n\tA\tMICROCAR\t80.00\t        BMW 600\n";
    cout << " \n\tB\tSALOON CAR\t120.00\t        AUDI A6\n";
    cout << " \n\tC\tMULTIPURPOSE\t180.00\t        ALZA\n";
    cout << " \n\tD\tMOTORCYCLE\t20.00\t        YAMAHA RXZ\n";
    cout << "\n--------------------------------------------------------------------------------\n";
    cout << "\n\t\t\t\tCONDITIONS\n\n";
    cout << "\n--------------------------------------------------------------------------------\n";
    cout << " - more than 300km\t\t: 50% is charged\n\n - less than 300km\t\t: 20% is charged\n";
    cout << " \n - Multipurpose car with TV\t: + RM 15.00\n\n - Regular customer(3 times)\t: 10% discount\n\n";
    cout <<"\n\n Press 1 to proceed: ";
    cin >> k;   
    system ("cls");
 }


 int listing::menuNext()
 {
     int option;
        cout<< "\n\nMAIN MENU\n";
        cout << "\n=============\n";
       cout<< "\n1. CREATE\n2. INSERTION\n3. DELETION\n4. PRINT LIST\n5. Rental Receipt\n6.EXIT ";
        cout<< "\n\nEnter one of the option\t:  ";
        cin>>option;

        switch(option)
     {
     case 1:
         createList();
         break;
     case 2:
         insertion();
         break;
     case 3:
        deletion();
         break;
     case 4: 
         display();
         break;
     case 5:
         rental_receipt();
         break;
     }
     return 0;


 }


 void listing::createList()
 {
     string name;
     int numberQ;
     char car;
     int s;
     int count = 0;
     int a;

     node *cur, *ptr;
     cout <<"\n====================\n\n";
     cout << "Enter the following information :\n";
     cout << "\nCustomer name\t=\t ";
     cin >> name;
     cout << "\nQueue\t\t=\t ";
     for ( numberQ = 0; numberQ < 1; numberQ++)
     {
     cout << numberQ + 1 << " / 2015\n";
     }
     cout << "\nCar Group\t=\t ";
     cin >> car ;
     cout<< endl;
     double total;
     char condition;
     switch (car){
     case 'A' :  microcar[0].car = "BMW 600 ";
                 microcar[0].cost = 80.00;
         cout << "Car Model\t=\t "<< microcar[0].car << endl;
                cout << "\nTotal distance\t=\t ";
                cin >> s;


                if (s <= 350)
                {

                total = 80.00*0.2;
                microcar[0].cost = microcar[0].cost + total;
                std::cout<< "\nTotal Millage\t=\t RM "<<microcar[0].cost << ".00\n";
                }
                else
                {
                total = 80.00*0.5;
                microcar[0].cost = microcar[0].cost + total;
                std::cout<< "Total Millage\t=\t RM "<<microcar[0].cost << ".00\n";
                }

                break;

     case 'B' :   saloon[0].car = "AUDI A6 ";
                 saloon[0].cost = 120.00;
         cout << "Car Model\t=\t "<< saloon[0].car << endl;
                cout << "\nTotal distance\t=\t ";
                cin >> s;


                if (s <= 350)
                {

                total = 120.00*0.2;
                saloon[0].cost = saloon[0].cost + total;
                std::cout<< "\nTotal Millage\t=\t RM "<<saloon[0].cost << ".00\n";
                }
                else
                {
                total = 120.00*0.5;
                saloon[0].cost = saloon[0].cost + total;
                std::cout<< "Total Millage\t=\t RM "<<saloon[0].cost << ".00\n";
                }
                break;
     case 'C' : multipurpose[0].car = "ALZA ";
                 multipurpose[0].cost = 180.00;
         cout << "Car Model\t=\t "<< multipurpose[0].car << endl;
                cout << "\nTotal distance\t=\t ";
                cin >> s;


                if (s <= 350)
                {

                total = 180.00*0.2;

                multipurpose[0].cost = multipurpose[0].cost + total;
                std::cout<< "\nTotal Millage\t=\t RM "<<multipurpose[0].cost << ".00 (without condition)\n";

                cout << "\nIncludes TV(Y/N) =\t ";
                cin>>condition;
                        {

                            if ( condition == 'Y' )
                            {

                                multipurpose[0].cost = multipurpose[0].cost + 15 - 36;
                            }
                            else  if ( condition == 'N')
                            {
                        std::cout<< "\nTotal Millage=\t RM "<<multipurpose[0].cost << ".00\n";
                            }
                            else
                        std::cout<< "\nTotal Millage\t=\t RM "<<multipurpose[0].cost << ".00\n";
                        }
                } //ENDIF
                else if ( s > 450 )
                {

                total = 180.00*0.5;
                multipurpose[0].cost = multipurpose[0].cost + total;
                std::cout<< "\nTotal Millage\t=\t RM "<<multipurpose[0].cost << ".00 (without condition)\n";

                cout << "\nIncludes TV(Y/N) =\t ";
                cin>>condition;
                        {

                            if ( condition == 'Y' )
                            {

                                multipurpose[0].cost = multipurpose[0].cost + 15;
                            }
                            else  if ( condition == 'N')
                        std::cout<< "\nTotal Millage=\t RM "<<multipurpose[0].cost << ".00\n";

                        }
                std::cout<< "T\n Total Millage\t=\t RM "<<multipurpose[0].cost << ".00\n";
                // END ELSE
                }
                break;
    case 'D' : motorcycle[0].car = "YAMAHA RXZ ";
                motorcycle[0].cost = 20.00;
         cout << "Car Model\t=\t "<<motorcycle[0].car << endl;
                cout << "\nTotal distance\t=\t ";
                cin >> s;


                if (s <= 350)
                {

                total = 20.00*0.2;
                motorcycle[0].cost = motorcycle[0].cost + total;
                std::cout<< "\nTotal Millage\t=\t RM "<<motorcycle[0].cost << ".00\n";
                }
                else
                {
                total = 20.00*0.5;
                motorcycle[0].cost = motorcycle[0].cost + total;
                std::cout<< "Total Millage\t=\t RM "<<motorcycle[0].cost << ".00\n";
                }
                break;
     }
      cout<<"Enter 0 to return to Main Menu :";
     cin>> a;

     while(a)
     {
         cur = new node;
         cur -> data = a;
         cur->link = NULL;
         if(first==NULL)
            first=cur;
         else
             ptr->link=cur;
             ptr=cur;
             cout<<"Enter 0 to return to Main Menu :";
             cin>> a;

     }
      system ("PAUSE");
     menuNext();
 }


     void listing::insertion()
 {
     node *cur, *ptr;
     int ele;
     int x;
     ptr = first;
     cur =new node;
     cout<<"\n Enter data of new node : ";
     cin >> cur->data;
     cur -> link = NULL;
     cout << "Do you want to add at beginning [ 1 for Yes / 0 for No] :"<< endl; // problem
     cin>> x;
     if (x==1)
     {
         cur->link=first;
         first= cur;
     }
     else
     {
         cout<< "\nPlese specify after which element you want to delete: ";
         cin>> ele;
         while (ptr != NULL)
         {
             if (ptr-> data ==ele)
             { 
                 cur -> link = ptr->link;
                 ptr->link= cur;
                 break;
             }

             else
             {
                 ptr = ptr-> link;
             }
         }
     }
    menuNext();
 }


 void listing:: deletion()
 {
     int ele;
     char ch;
     node *ptr, *ptr1;
     if (first==NULL)
     {
         cout<< "LIST IS EMPTY\n";
     }
     else
     {
         ptr = first;
         cout << "Delete the first element? [y/n] : ";
         cin >> ch;
         if (ch == 'Y' || ch == 'y')
         {
             first= first -> link;
             delete ptr;
         }

         else
         {
             cout<<"\n Specify which element u want to delete : ";
             cin >> ele;

             while (ptr != NULL)
             {
                 if (ptr-> link-> data ==ele)
                 {
                     ptr1=ptr->link;
                     ptr->link = ptr1-> link;
                     delete ptr1;
                     return;
                 }
                 else
                 {
                     ptr=ptr->link;
                 }
             }
         }
     }
    menuNext();
 }

 void listing::search()
 {

     search();
     {
         node *head;
         head=new node;
     }

     void build(struct nodes**,int);
 {
     struct nodes *head=NULL;
     int r,num;
     struct nodes *tempo;

     for(r=0;r<num;r++)
     {
         tempo=(struct nodes *)malloc(sizeof(struct nodes));
         tempo->s = rand()/num;
         if(head==NULL)
         {
             head=tempo;
             tempo->next=NULL;
         }
         else
         {
             tempo->next=head;
             head=tempo;
         }
         cout<<" "<<tempo->s;
     }
 }
 void search(struct nodes*,int);
 {
     int key;
     struct nodes *head=NULL;
     while (head!=NULL)
     {
         if(head->s == key)
         {
             cout<<"Found the key!\n";
             return;
         }
         head=head->next;
     }
     cout<<" Could not find the key!\n";
 }
 void dlte(struct nodes **);
 {
     struct nodes *head=NULL;
     struct nodes *tempo;
     while(head!=NULL)
     {
         tempo=*head;
         *head=(*head)->next;
         free(tempo);
     }
 }
 }

 void listing::calculate()
 {
     int calculation;
     int millage;
     int distance;

     calculation = millage*distance;

     cout<<"Your distance is "<<distance<<endl;
     cout<<"Your millage is "<<millage<<endl;
     cout<<"Your total is "<<calculation<<endl;
 }

 void listing::display()
 {
     node *ptr;
     if (first==NULL)
     {
         cout<<"List is empty.\n";
     }
     else
     {
         ptr = first;
         while (ptr != NULL)
         {
              ptr = ptr-> link;
            cout<<"Car Type : "<<ptr->car<<endl;
            cout<<"Distance : "<<ptr->distance<<endl;
            cout<<"Price : "<<ptr->cost<<endl;
             ptr = ptr-> link;
         }
     }
    menuNext();

 }

 void listing::rental_receipt() //Function to print receipt
{
    int choice, count = 1, count1 = 1;
    char car[10];
    char day,name,nationality;
    int currency;

    node *head;
    head = first;
    cout << "Enter Name to print Receipt: " << endl;
    cin >> name;
    cin>>choice;
    cout << " " << endl;

    while (head != NULL && head->name != choice)
    {
        count++;
        *head = head->next;
    }
    if (head == NULL)
    {

        cout << "\t\t ***Receipt on Kenyalang Car Rental Centre***\n" << endl;
        cout << "Customer's Name: \n" << head->name;
        cout<<"Nationality : \n"<<head->nationality;
        cout<<"Currency : \n"<<head->currency;
        cout << "___________________________________________________________________" << endl;
        cout << "Car Type\tCost\tDistance\tMillage\t" << endl;
        cout << "___________________________________________________________________" << endl;
        cout << head->car << "\t\t" << head->cost << "\t\t    " << head->distance << "\t\t" << head->millage << endl;

        head = head->next;
        while (head != NULL && head->name == choice && count1<4)
        {
            cout << head->car << "\t\t" << head->cost << "\t\t    " << head->distance << "\t\t" << head->millage << endl;

            count1++;
            head = head->next;
        }
    }
    else
    {
    cout << "Error. Enter a valid name." << endl;
    }
    getchar();
    system("PAUSE");
    menuNext();
}

 void listing::rental_report()//report for the day
 {
     node *report;
     report = first;

     int sum_car_rented=0,sum1=1;
     int number=0,total_car=0;
     char day[10];
     _strdate_s(day);

     total_car=total_car + report->number;

     cout<<"\t\t ***Receipt on Kenyalang Car Rental Centre***\n" << endl;
     cout<<"\t\t Daily Summary Report \n";
     cout<<"\t\t Date: \n"<<day;

     cout<<"---------------------------------------------------------\n";
     cout<<"No. \t\t Customer Name \t\t Car \t\t Total \t\t \n";
     cout<<"---------------------------------------------------------\n";

     if(total_car>50)
         cout<<sum1<<"\t\t Car \t\t"<<total_car<<"Overtime \n";
     else
         cout<<sum1<<"\t\t Car \t\t"<<total_car<<"Overtime \n";

            number=total_car;
            sum_car_rented=total_car-25;
            cout<<"------------------------------------------------------\n";
            cout<<"\t\t Total Car Rented : "<<number<<endl;
            cout<<"\t\t Total Car Overtime : "<<sum_car_rented<<endl;
 }



 int main()
 {
     char n;
     listing menu;

      menu.menuFirst();
      int m;
    char array[50];
    insertionsort(array,50);

    struct nodes *head=NULL;
    int num,key;

      bool run  = true;
     do
     { 
         cout<< "\n\nPLEASE USE CAPSLOCK THROUGHOUT THE WHOLE SESSION\n\n";
        menu.menuNext();


         std::cin>> n;

     }while(n>4);

     Stack stck;
     int D1,ch;


         cout<<"Press 1 to push \n Press 2 to pop \n Press 3 to display \n Press 4 to exit";
         cin>>ch;

         switch(ch)
         {
         case 1: cout<<"Enter the data : ";
             cin>>ch;
             stck.push(ch);
             break;

         case 2: cout<<"Deleted the \n"<< stck.pop();
             stck.display();
             break;

         case 3: stck.display();
             break;
         case 4: exit(0);

         }

    cout<<"Enter number of nodes : ";
    cin>>num;
    cout<<"Display list \n";
    build(head,num);

    cout<<"Enter search key : ";
    cin>>key;
    search(head,key);
    search *head=new head();
    delete head;//head:~head()


    getchar();
    system("PAUSE");
    return 0;
}

Tell us the first error.

i managed to solve 4 errors, so it left with 22 errors. the errors are most caused by pointer 'tempo'( function void build), 'head','node' pointer and cannot input cin nationality.

i managed to solve 4 errors, so it left with 22 errors. the errors are most caused by pointer 'tempo'( function void build), 'head','node' pointer and cannot input cin nationality.

Again, tell us the first error. If there is an error, there is an error message. Tell us that error message.

also the insertionsort(array,50) on main function

error c2027 : use of undefined type 'nodes'

Right, yes, again, you're not telling us the error. If you can identify an error, then there is information about that error. Identify the first error, tell us what that error is.

It would help if you would completely re - design your code ...

You are best to use the standard C++ containers ...

like vector, list, stack, etc ...

rather than messing around with your 'nodes', etc...

Also, build your code in steps, fixing each step as you go,
and keeping copies of all the previous WORKING stages ...

(A 'working stage' is code that gives the exact expected output for all the possible input at that stage.)

Then ... you can always go back to a previous 'working stage' ...

and start over from there,

if you cannot find the latest new 'bug'.

So ... show us the code for a 'working stage' ...

and then,

only the very next part that was added where you need help to see the 'bug'.

Also ... see changes

include <string>
#include <cstdlib>
#include <iostream>
// #include<malloc.h> // in C++ use new, but better to use C++ vector, etc
#include <fstream>
#include <ctime> //#include<time.h>
// #include<conio.h> // Do NOT use to keep your code portable //

// using namespace std; // bad idea to do this in big project //

const int SIZE = 10; //#define SIZE 10 // better C++ style ...

Also ...
break up your classes into their own files
(but you do not need so many classes ...
if you use C++ list and vector, etc... containers.)

This (old) example may help your re-design ...

http://developers-heaven.net/forum/index.php/topic,2585.0.html

error c2027 : use of undefined type 'nodes'

Line 35, you're using "nodes". What is a "nodes"? There is no such thing as a "nodes"? Did you mean "node"?

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.