Using Structures as parameters in Functions

I keep getting an error. My compiler says" error:'TopLevel' does not refer to a value." This error occurs on line 49 in the code pasted here. I really don't understand. My text didn't cover using functions and structures together. Help!

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
 #include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

using namespace std;

void Process();
void Input(ifstream&,string&);
void Output(ofstream&,string&); 

struct Date
	{...};
	
struct RenewInfo
	{...};
	
struct SubName
	{...};

struct Address
	{...};
	
struct TopLevel
	{
	SubName subscriberName;
	Address address;
	Date expirationDate;
	RenewInfo renewal_information;
	};

int main()
{
	ifstream inFile;
	ofstream outFile;
	string fileName;
	
	Input(inFile,fileName);
	Output(outFile, fileName); 
	Process();
	
	return 0;
}

void Process()
{
	ifstream inFile;
	
	inFile >> TopLevel.SubName;
	
	return;
}

void Input(ifstream& inFile, string& fileName)
{...}

void Output(ofstream& outFile,string& fileName)
{...}
TopLevel is a struct definition. You need to instantiate it first, before you can do anything to it.
Try something like
1
2
3
4
5
6
7
8
9
void Process()
{
	ifstream inFile;
        TopLevel myTopLevelObject;
	
	inFile >> myTopLevelObject.SubName;
	
	return;
}
Thank you so much!!!!

The way you wrote that out really helped.

It may not seem like much, but you've helped me over a big hurdle.

Thank you again!!!!!!
Topic archived. No new replies allowed.