writing file << illegal for class

when trying to enter the username, password, bookname dates, and length of stay every error is the title: << illegal for class.

here's the code. sorry for all the questions

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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// newproject2.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>

using namespace std;

class userMenu{
public:
	userMenu();
	string homeMenu;
	string add;
	string remove;
	string edit;
};		//webUser menu class

userMenu::userMenu(){
	cout<<"Select an option below (1,2,3)"<<endl
		<<"1.  Add Booking"<<endl
		<<"2.  Edit Booking"<<endl
		<<"3.  Remove Booking"<<endl;
};


class addBooking{			
	public:
	addBooking();
	string addMenu;
	string bookName;
	int startDate;
	int currentDate;
	int lengthStay;
};							//add booking class

addBooking::addBooking(){
	cout<<"Welcome to the Add Booking Menu!:"<<endl;
};			 //contructor  

class rates{
public:
	rates();
	int displayMonthRates();
	int displayWeekRates();
	int displayDayRates();
	int monthRate;
	int weekRate;
	int dayRate;
};

rates::rates(){

	dayRate=100;
	weekRate=525;
	monthRate=1575;
};





class newUser{				//new user class

public:
	newUser();
	string name;
	string password;
	
};		
newUser::newUser(){		//new user constrctor

	

};	 


int main(){

	
	

	ofstream reservationFile;												//creating output stream file to write reservation input

	reservationFile.open("reservationLog.txt");
	if(reservationFile.fail()){
		cout<<"File reservation unsuccessfully opened."<<endl
			<<"Please check to see if file exists."<<endl;
		exit(1);
	}


	

	ofstream userFile;													//create output stream file to write user login input

	userFile.open("userinfo.txt.");
	if(userFile.fail()){
		cout<<"File userinfo unsuccessfully opened."<<endl
			<<"Please check to see if file exists."<<endl;
		exit(1);
	}

	cout<<"\n the file userinfo.txt has been successfully opened for writing."<<endl;


	ifstream reservationFile;
	reservationFile.open("reservation.txt");
	if(reservationFile.fail()){
		cout<<"File cannot be opened."<<endl
			<<"Please check to see if File exists."<<endl;
	}

	cout<<"\n the file reservation.txt has been successfully opened for writing."<<endl;

	

	cout<<"Welcome new user!:"<<endl;

	int add=1;
	int edit=2;
	int remove=3;
	newUser newUserOne;
	int opselect;

	
	cout<<"Please enter user name:"<<endl;					//enter username
	userFile<<newUserOne.name;								//write username to userFile	
		cout<<endl;
	cout<<"Please enter passworrd:"<<endl;					//enter password
		userFile<<newUserOne.password;						//write password to user file

		userMenu menuOne;									
		do{
		cout<<menuOne.homeMenu<<endl;						//display menu
		cin>>opselect;
		switch(opselect){								//switch statement to help with menu selection
		case 1:{				//selected add bookin menu
			
				cout<<"If Booked 2 weeks in advanced, 3% off lodging only"<<endl;			
				addBooking addMenu;
				cout<<"Please enter book name:"<<endl;								//enter book name
				reservationFile<<addMenu.bookName;									//write book name to reservationFile file
				cout<<endl<<"please enter toady's date(yyyymmdd):"<<endl;			//enter current date
				reservationFile<<addMenu.currentDate;								//write current date to reservationfile
				cout<<endl<<"please enter start date:(yyyymmdd)"<<endl;				//enter start date
				reservationFile<<addMenu.startDate;									//write start date to reservationfile
			 
				rates showRate;

				cout<<"Monthly Rate:"<<showRate.monthRate<<endl				//display month rate
					<<"Weekly Rate:"<<showRate.weekRate<<endl				//display week rate
					<<"Daily Rate:"<<showRate.dayRate<<endl;				//display day rate

				cout<<"Please enter length of stay:"<<endl;						//enter length of stay
				reservationFile<<addMenu.lengthStay;							//write length of stay to reservation file


				cout<<addMenu.lengthStay/30<<"Months"<<endl							//use algorithm to find out # of months,weeks, and days
				<<addMenu.lengthStay%30/7<<"Weeks"<<endl
				<<addMenu.lengthStay%30%7<<"Days"<<endl;
			   }
			break;
			   
		case 2:{																//case to to edit book menu
			
				cout<<"Welcome to the edit booking menu!"<<endl;

				
			}
				break;
		

		case 3:{
			
				cout<<"welcome to the remove booking menu!:"<<endl;
			
				break;
			}
		}}
		while(opselect==1&& opselect==2&& opselect==3);						//while loop (may be wrong) to loop back to start of menu (may need help editting it
			   
			return 0;
}
1
2
ofstream reservationFile; //line 85
ifstream reservationFile; //line 109 
¿which one is it?
i don't exactly know. i need it to write to the file, but then read from it later. how would i code that?
Topic archived. No new replies allowed.