ERROR on compiling

Hi.I made some header files with their cpp.Everything was fine but when i made a function on one of my header's and i try to compile i get this:
error: 'ListC' has not been declared.

What can i do?
here are the 2 headers and their cpp.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef DVDLIST_H_INCLUDED
#define DVDLIST_H_INCLUDED
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include "Customers.h"


using namespace std;

typedef struct dvdtype{//orismos typoy dedomenon dvd
	int dvdcode; //kodikos tainias
	char title[50]; //titlos tainias
	int customerID; //peelaths poy thn exei enoikiasei
	int daysowned; //meres poy thn exei krathsei thn tainia o pelaths
    struct dvdtype *next;
}dvdtype;

typedef struct ListD{ //h domh poy sozoyme ola ta dvds (ena array kai
		      //enas counter poy deixnei thn teleytaia eggrafh
	dvdtype *head; //to dynamiko array
	int numdvds; //o counter poy deixnei poses tainies yparxoyn
}ListD;

int deleteMovie(ListD *dvds);
int readMovieFromKbd(ListD *dvds);

void initDvdList(ListD *dvds);
void printMovies(ListD *dvds);

void returnMovie(ListD *dvds);
void stepOneDay(ListD *dvds);
void rentMovie(ListD *dvds,ListC *l); //Here i get the Error

#endif // DVDLIST_H_INCLUDED 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef CUSTOMERS_H_INCLUDED
#define CUSTOMERS_H_INCLUDED
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include "dvdlist.h"
#define NameLength 100

using namespace std;

typedef struct CustomersData{
    char cstname[NameLength];
    char cstsrname[NameLength];
    int  cstID;
    struct CustomersData *next;
}Customers;

typedef struct ListCustomers{
    Customers *head;
}ListC;

void initCustomersList(ListC *l);
int insertAtHeadCustomers(ListC *l);
int assortListofCustomers(ListC *l,int key);
void displayList(const ListC *l);
int De_ListofCustomers(ListC *l,int key);
void printfCustomerMovies(ListC *l,ListD *dvds);

#endif // CUSTOMERS_H_INCLUDED 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include "Customers.h"
#include "dvdlist.h"
#include "mainfunctionlist.h"

using namespace std;

void initCustomersList(ListC *l){
	l->head=NULL;
}

int insertAtHeadCustomers(ListC *l){
	Customers *newnode, *cur;

	newnode=(Customers*) malloc(sizeof(Customers));
	if (newnode==NULL) return 0;
	cout<<"Give Customer Name:";
    gets(newnode->cstname);fflush(stdin);
    cout<<"Give Customer Surname:";
    gets(newnode->cstsrname);fflush(stdin);
    cout<<"Give Customer ID:";
    cin>>newnode->cstID;fflush(stdin); while(newnode->cstID==0) {cout<<"You cant give Zero for ID.Try again"; cin>>newnode->cstID;fflush(stdin);}
	newnode->next=l->head;
	l->head=newnode;cur=newnode->next;
    while(cur!=NULL){
        if(cur->cstID==newnode->cstID) {cout<<"Customer ID already exist.Try again:";cin>>newnode->cstID;fflush(stdin);}
        cur=cur->next;
    }
	return 1;
}

void displayList(const ListC *l){
	Customers *cur;
	cur=l->head;
	while (cur!=NULL){
		cout<<"Customer Name is:"<<cur->cstname<<endl;
		cout<<"Customer Surname is:"<<cur->cstsrname<<endl;
		cout<<"Customer ID is:"<<cur->cstID<<endl;
		cur=cur->next;
        cout<<endl;
	}
    free(cur);
}

int assortListofCustomers(ListC *l,int key){
    Customers *cur;
    int x,z,temp,guard=0;
    char temp1[NameLength],temp2[NameLength];

    cur=l->head;

  //f8inousa
for(x=0;x<key;x++)
  while(cur->next!=NULL) {
           z=strcmp((cur->cstname),((cur->next)->cstname));
            if(z>0){//kata onoma
                    temp=cur->cstID;
                    strcpy(temp1,cur->cstname);
                    strcpy(temp2,cur->cstsrname);

                    cur->cstID=((cur->next)->cstID);
                    strcpy(cur->cstname,((cur->next)->cstname));
                    strcpy(cur->cstsrname,((cur->next)->cstsrname));

                    ((cur->next)->cstID)=temp;
                    strcpy(((cur->next)->cstname),temp1);
                    strcpy(((cur->next)->cstsrname),temp2); guard++;
                }
              else if(z==0){

                     z=strcmp((cur->cstsrname),((cur->next)->cstsrname));
                  if(z>0){//kata epitheto an kapoio onoma einai idio
                        temp=cur->cstID;
                        strcpy(temp1,cur->cstname);
                        strcpy(temp2,cur->cstsrname);

                        cur->cstID=((cur->next)->cstID);
                        strcpy(cur->cstname,((cur->next)->cstname));
                        strcpy(cur->cstsrname,((cur->next)->cstsrname));

                        ((cur->next)->cstID)=temp;
                        strcpy(((cur->next)->cstname),temp1);
                        strcpy(((cur->next)->cstsrname),temp2);guard++;
            }
        }
       cur=cur->next;
    }
  return guard;
}

int De_ListofCustomers(ListC *l,int key){
	Customers *cur, *prev;

	//if(l->head==NULL) return 0;

	prev=NULL;cur=l->head;
	while (cur!=NULL && cur->cstID!=key){
		prev=cur;
		cur=cur->next;
	}
	if (cur==NULL) return 0;

	if (prev==NULL) l->head=l->head->next;
	else prev->next=cur->next;
	free(cur);
	return 1;
}

void printfCustomerMovies(ListC *l,ListD *dvds){
 Customers *test;
 dvdtype *cur;
 char name[NameLength],srname[NameLength];
 int id=0;

 cur=dvds->head;
 test=l->head;
 if(test==NULL) cout<<"There are no customers registered";
 else {
 cout<<"Give me customer name :";
 gets(name);fflush(stdin);cout<<"Give me customer surname :"; gets(srname);fflush(stdin);
 while(test!=NULL) {
    if(strcmp(test->cstname,name)==0 && strcmp(test->cstsrname,srname)==0) id=test->cstID;
    test=test->next;
 }
  if(cur==NULL) cout<<"There are no registered movies";
  cout<<"Movies owned to :";cout<<name << srname<<endl;
  while(cur!=NULL){
     cout<<cur->title<<endl;
     cur=cur->next;

  }
 }
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "dvdlist.h"
#include "Customers.h"
#include "mainfunctionlist.h"

using namespace std;

void initDvdList(ListD *dvds){

 dvds->head=NULL;
 dvds->numdvds=0;
}

int readMovieFromKbd(ListD *dvds){
  dvdtype *newnode;

  newnode=(dvdtype*) malloc(sizeof(dvdtype));
   if (newnode==NULL) return 0;

    cout<<"Give me DvD Code:";
    cin>>newnode->dvdcode;
    cout<<endl;
    cout<<"Give me the Title of the movie:";fflush(stdin);
    gets(newnode->title);
    while(strlen(newnode->title)>=50){
        cout<<"Wrong Input,Title too big.Try again"<<endl;
        cout<<"Title of the movie:";gets(newnode->title);
        fflush(stdin);system("cls");
    }
    newnode->customerID=-1;
    newnode->daysowned=-1;

	newnode->next=dvds->head;
	dvds->head=newnode;
	dvds->numdvds++;

return 1;
}

int deleteMovie(ListD *dvds){
 dvdtype *cur, *prev;
 int key,found;

    cout<<"Give me movie code to delete:";cin>>key;
	prev=NULL;cur=dvds->head;
	while (cur!=NULL && cur->dvdcode!=key){
		prev=cur;
		cur=cur->next;
	}
	if(cur->dvdcode==key) found=1;
	if (cur==NULL) return 0;
	if(found==1){
        if(cur->daysowned==-1){
            if (prev==NULL) dvds->head=dvds->head->next;
            else prev->next=cur->next;
            cur->next=NULL;
            free(cur);
        }
        else
            cout<<"Movie cant be deleted.It is rented";
        return 1;
    }
    return 1;
}

void printMovies(ListD *dvds){
 dvdtype *cur;
 int i=1;

  cur=dvds->head;
  if(cur==NULL) cout<<"There are no registered movies";
  cout<<"Movie";gotoxy(0,51);cout<<"DvD Code";
  while(cur!=NULL){
     gotoxy(i,0);
     cout<<cur->title;
     gotoxy(i,51);
     cout<<cur->dvdcode;
     cur=cur->next;
     i++;
  }
}

void rentMovie(ListD *dvds,ListC *l){
 dvdtype *cur;
 Customers *test;
 char name[NameLength],srname[NameLength];
 int id=0,code,done=0;

 cur=dvds->head;
 test=l->head;

 cout<<"Give me customer name :";
 gets(name);fflush(stdin);cout<<"Give me customer surname :"; gets(srname);fflush(stdin);
 while(test!=NULL) {
    if(strcmp(test->cstname,name)==0 && strcmp(test->cstsrname,srname)==0) id=test->cstID;
    test=test->next;
 }
 if(id!=0) {
    cout<<"Give me Movie code to rent :";cin>>code;
    while(cur!=NULL){
        if(cur->dvdcode==code) {
            cur->customerID=id;
            cur->daysowned=1;
            done=1;
        }
        cur=cur->next;
    }
    if(done==0) cout<<"There is no Movie with such code";
 }
  else cout<<"There is no customer registered with that arguments";
}
Last edited on
i made a function on one of my header's and i try to compile i get this:
error: 'ListC' has not been declared.

You need to display the error message verbatim. The compiler has told you exactly what's wrong, but you've stripped off all the useful information thqat shows where the error is.
One problem I see is that you have circular includes.
DVDLIST.h includes CUSTOMERS.h
CUSTOMERS.H includes DVDLIST.h

You do have include guards, so when DVDLIST.h includes CUSTOMER.h which in turn includes DVDLIST.h again, the second inclusion will be skipped, but this is poor practice.

Try changing this:
void printfCustomerMovies(ListC *l,ListD *dvds);
to:
void printfCustomerMovies(struct ListCustomers * l,ListD *dvds);

Thanks both of you.
I tried what you told me.it seems to work.i will test it latter and let you know.
Topic archived. No new replies allowed.