I am making Railway reservation sys. i want to pass these set of statements into a function how can i do that???? I have used structures in the program...

cout<<"--TICKET SUMMARY--"<<endl;
				cout<<"Passenger Name :"<<o2.pass_name<<endl;
				cout<<"Age :"<<o2.age<<endl;
				cout<<"Sex :"<<o2.sex<<endl;
				cout<<"Train Name: "<<o1[x].train_name<<endl;
				cout<<"Arrival Time: "<<o1[x].t_arr.hrs<<":"<<o1[x].t_arr.min<<endl;
				cout<<"Departure Time: "<<o1[x].t_dep.hrs<<":"<<o1[x].t_dep.min<<endl;
				cout<<"Seat Class: 2A"<<endl;
				cout<<"Seats Reserved: "<<o2.sts_req<<endl;
				cout<<"Seats Left Unreserved:"<<seats_left(o1[x].ac_sts, o2.sts_req)<<endl;
				cout<<"Ticket Price: Rs."<<o2.amt<<endl;

plzzz help!!!

6 Years
Discussion Span
Last Post by Ancient Dragon

You didn't tell us the name of the structure or its contents, but basically something like this:

struct something
  // blabla

void foo( struct something& n)


int main()
   struct something s;
   foo( s );

i havent put the full code of my program above, so dont get confused...
here are the structures.....

struct train_info
	char train_name[25];// Train Name
	int t_number, op_days, ac_sts, twoa_sts, thra_sts, slp_sts, ac_sl, twoa_sl, thra_sl, slp_sl;
	time t_dep, t_arr;// Time of Departure and Arrival
	int ac_rt , twoa_rt, thra_rt, slp_rt; // Rates of AC, 2A,3A, Sleeper Class

struct pass_info
	char pass_name[30], sex, css;// Passenger Name, Sex, Class(AC, 2A or 3A, SLP)
	int age, sts_req, t_no;
	int amt;

AD is not confused he gave you a generic example. Take his function and modify it to 2 arguments of the appropriate classes.

Edited by Fbody: n/a


Just pass them to your functions something like I posted before. That code shows how to pass them by reference, meaning that additional memory will not be consumed like it is when passing something by value.

If you want to pass both structures, then add more parameters to the function.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.