Jump to content

Hey guys, for my assignment I have to have a linear linked list of stuff. My

problem right now is that i keep getting the error code of head is not

declared in main. I'm also getting other errors relating to my class as I am

not 100% proficient on classes.

http://pastebin.com/XX4iUUU4 - functions

http://pastebin.com/P2VduBQX - header file

http://pastebin.com/EfQMpxaQ - main

Here is a screengrab of the error code I'm getting. If someone

could help with the other error codes that would help a lot. Thanks

in advance for any tips.

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
https://linustechtips.com/topic/583392-head-not-declared-help-c/
Share on other sites

Link to post
Share on other sites

I'm pretty sure you can't assign NULL to head like that. I thought that you could only do a pointer to NULL.

[Out-of-date] Want to learn how to make your own custom Windows 10 image?

 

Desktop: AMD R9 3900X | ASUS ROG Strix X570-F | Radeon RX 5700 XT | EVGA GTX 1080 SC | 32GB Trident Z Neo 3600MHz | 1TB 970 EVO | 256GB 840 EVO | 960GB Corsair Force LE | EVGA G2 850W | Phanteks P400S

Laptop: Intel M-5Y10c | Intel HD Graphics | 8GB RAM | 250GB Micron SSD | Asus UX305FA

Server 01: Intel Xeon D 1541 | ASRock Rack D1541D4I-2L2T | 32GB Hynix ECC DDR4 | 4x8TB Western Digital HDDs | 32TB Raw 16TB Usable

Server 02: Intel i7 7700K | Gigabye Z170N Gaming5 | 16GB Trident Z 3200MHz

Link to comment
https://linustechtips.com/topic/583392-head-not-declared-help-c/#findComment-7612226
Share on other sites

Link to post
Share on other sites

You are trying to assign NULL to the variable headHead doesn't exist.

What are you trying to accomplish on line 5:

#include "program1header.h"
using namespace std;
int main()
{
	head = NULL; // <-- What is this line trying to accomplish?
	struct flightInfo flights;
	char TSA;
	char flight_type;
	char * search[20];
	cout << "Are you flying TSA pre-check? (Y/N)" << endl;
	cin >> TSA;
	cin.ignore(100, '\n');
	cout << "Customs or Immigration? (Y/N)" <<endl;
	cin >> flight_type;
	cin.ignore(100, '\n');
	node * head = NULL;
	make(flightInfo * flights);

	return ;
}

 

Are you trying to create a new node called head and assign NULL to head? That should be done like follows:

node *head = NULL;

 

Link to comment
https://linustechtips.com/topic/583392-head-not-declared-help-c/#findComment-7612504
Share on other sites

Link to post
Share on other sites

28 minutes ago, PlutoNZL said:

You are trying to assign NULL to the variable headHead doesn't exist.

What are you trying to accomplish on line 5:


#include "program1header.h"
using namespace std;
int main()
{
	head = NULL; // <-- What is this line trying to accomplish?
	struct flightInfo flights;
	char TSA;
	char flight_type;
	char * search[20];
	cout << "Are you flying TSA pre-check? (Y/N)" << endl;
	cin >> TSA;
	cin.ignore(100, '\n');
	cout << "Customs or Immigration? (Y/N)" <<endl;
	cin >> flight_type;
	cin.ignore(100, '\n');
	node * head = NULL;
	make(flightInfo * flights);

	return ;
}

 

Are you trying to create a new node called head and assign NULL to head? That should be done like follows:


node *head = NULL;

 

I was doing that to try and test if that would get the error gone, will try what you recommended 

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
https://linustechtips.com/topic/583392-head-not-declared-help-c/#findComment-7612604
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×