struct type arrays

I have an array that I want each element of to be a data structure. I then want to pass the array on to different functions where it is needed. The problem is that my prototypes for my functions are in another file that is a .h file. The struct isn't defined until after the prototype.h file in my main() function so I get the following error:

error 2065: design not a valid identifier

Is there a way to move something or someother way so that it recognizes the design data type?

Here is the code in both files:

prototype.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef _STATIONARYSHOPPROTOTYPES_H_
#define _STATIONARYSHOPPROTOTYPES_H_

void informationCollection ();
void informationCheck (string&, string&, string&, string&, string&, string&, string&, string&);
void zipTest (string& zip);
void infoFormat (string&, string&, string&, string&, string&);
void printInvoice (string, int);
void administrator(design southwestDesigns[], design onTheBorderDesigns[]);
void stateTest(string& state);
void phoneTest (string&);
void displayInformation (string, string, string, string, string, string, string, string);
void timeHeader();
void order (string header);
void clrscr ();
void stationaryDataSet (design[], design[]);

#endif 


and the first bit of my main file

main.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
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cctype>
#include <string>
#include <windows.h>
#include "time.h"

using namespace std;

#include "errors.h"
#include "stationaryShopPrototypes.h"
#include "color.h"

double TAX_RATE = .0925;

void main()
{
	int choice;
	struct design
	{
		string name;
		float sheetPrice = 0;
		float envelopePrice = 0;
		int sheetsInStock = 0;
		int envelopesInStock = 0;
	}

	design southwestDesigns [10];
	design onTheBorderDesigns [10];


Obviously that isn't the entire main file but the error is happening in the prototype.h file and the struct is defined at the begining of the main.cpp file.

Thanks in advance for your help.
Simply move the structure definition to prototype.h :

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
#ifndef _STATIONARYSHOPPROTOTYPES_H_
#define _STATIONARYSHOPPROTOTYPES_H_

struct design
{
	string name;
	float sheetPrice = 0;
	float envelopePrice = 0;
	int sheetsInStock = 0;
	int envelopesInStock = 0;
};

void informationCollection ();
void informationCheck (string&, string&, string&, string&, string&, string&, string&, string&);
void zipTest (string& zip);
void infoFormat (string&, string&, string&, string&, string&);
void printInvoice (string, int);
void administrator(design southwestDesigns[], design onTheBorderDesigns[]);
void stateTest(string& state);
void phoneTest (string&);
void displayInformation (string, string, string, string, string, string, string, string);
void timeHeader();
void order (string header);
void clrscr ();
void stationaryDataSet (design[], design[]);

#endif  
I was hoping there was a way to keep from moving it there. The idea is to keep these things separate to help with organization of the program. Thanks for the help though. I'll do that.
Well, if you prefer, you could also use a forward declaration:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef _STATIONARYSHOPPROTOTYPES_H_
#define _STATIONARYSHOPPROTOTYPES_H_

struct design;

void informationCollection ();
void informationCheck (string&, string&, string&, string&, string&, string&, string&, string&);
void zipTest (string& zip);
void infoFormat (string&, string&, string&, string&, string&);
void printInvoice (string, int);
void administrator(design southwestDesigns[], design onTheBorderDesigns[]);
void stateTest(string& state);
void phoneTest (string&);
void displayInformation (string, string, string, string, string, string, string, string);
void timeHeader();
void order (string header);
void clrscr ();
void stationaryDataSet (design[], design[]);

#endif  


and define the structure in some other header file, which you don't need to include in protocol.h (but in protocol.cpp and main.cpp).
Topic archived. No new replies allowed.