"customerList" is not a type name?

Hey,
Looking through a program that was sent to be as part of my course from a demonstrator. I downloaded it as is and opened it up in Visual studio.

At a part of it, which has a comment beside it saying global class, there is an error coming up.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "customerList.h"		// NB. also includes customer.h
#include <iostream>				// cout
#include <fstream>				// ifstream

#define FN "bank0.txt"	// hardwired file name

customerList customerList;		// global customerList

int main()
{

	//
	// read in data from customer.txt
	//

	//
	// generate result file


	return 0;
}


The bold part of code is the bit that has a red line under it. When I put my mouse over it, it says error: variable "customerList" is not a type name.

Is this code wrong? How do I get rid of the error?
customerList is a user defined data type (or in this specific case, a "demonstrator" defined one.) Make sure "customerList.h" is in the correct directory, and is being included properly. If it is, check to make sure there are no compilation errors in that class (and file.)
Also you can't have your instance be named the same as the class itself.
Thanks.
Small mistype for the #include
All fixed and working well.

EDIT: It seems to work ok with the instance and the class named the same.
Last edited on
No, they can't be the same. There is no way to tell by context which you might want.
When you want to do that:
1
2
3
4
5
6
7
8
namespace CL
{
    #include "customerList.h"
}

//...

CL::customerList customerList;


This works, but please don't do it, and also don't name an instance of a class the same as the class name itself unless it is already in a namespace.
Topic archived. No new replies allowed.