Calling a value from a class to a different class

So as the title says, is there a way to call a value of a class user defined function to another class user defined funtion?... for my code below i would like to use the values that i have in string userinfo() and display them at void view() , please teach me

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
  #include <iostream>//i/o
#include <cmath>//math expressions
#include <iomanip>//i/o manipulations
#include <string>//string values
#include <fstream>//to read from a file

const double waterrate=108.01198630; //php per cu.m
const double elecrate=8.1081729;//php per kWh
using namespace std;
class info
{
	protected:
	string Lname;
	string Fname;
	string branch;
	string add;
	public:
	string userinfo()
	{
		
		cout<<"\nenter User first name and last name:";
		cin>>Fname>>Lname;
		cout<<"\nEnter from which branch you are paying: ";
		cin>>branch;
		cout<<"\nEnter your Home address: ";
		cin>>add;
		
		cout<<"\nUser name:\t"<<Fname<<" "<<Lname<<endl;
		cout<<"\nPayment Branch: "<<branch<<endl;
		cout<<"\nUser Address: "<<add<<endl;
		
		return Fname;
		return Lname;
		return branch;
		return add;
		
		}	
	/*void info.userinfo()
	{
		cout<<"\nUser name:\t"<<Fname<<" "<<Lname<<endl;
		cout<<"\nPayment Branch: "<<branch<<endl;
		cout<<"\nUser Address: "<<add<<endl;
		
		
	}*/
};

class waterbill//inputs and compus of water
{
	private:
		double prevmetrRead, currntmetrRead;
		public:
		double wamnt;
		
	public:
		double wcost()
		{
			cout<<"enter your previous water reading: ";
			cin>>prevmetrRead;
			cout<<"enter your current water reading: ";
			cin>>currntmetrRead;
			
			wamnt=abs(prevmetrRead-currntmetrRead)*waterrate;
			cout<<"your total water balance is : "<<wamnt<<" "<<"php"<<endl;
			
			
			return wamnt;
		}
};

class electricbill//input and compus of electric bill
{
	private:
	double prevmetrRead, currntmetrRead;
	public:
	double eamnt;
	public:
		double ecost()
		{
			cout<<"enter your previous Electricity reading: ";
			cin>>prevmetrRead;
			cout<<"enter your current water reading: ";
			cin>>currntmetrRead;
			
			eamnt=abs(prevmetrRead-currntmetrRead)*elecrate;
			cout<<"your total water balance is : "<<eamnt<<" "<<"php"<<endl;
			
			return eamnt;
		}
		
};

class viewuserinfofromthemenu
{
	protected:
		void view()
		{ 
			//HERE	
		}	
};





int main()//main function
{
	
	info i;
	waterbill w;
	electricbill e;
	int select;
	i.userinfo();
	
	cout<<endl;
	cout<<endl;
	cout<<"welcome to _______ bayad center";
	cout<<"\nPlease Select an option\n\n1.Compute Electricity Balance\n2.Compute Water Balance\n3.Settle Charges\n4.View UserInfo\n5.Exit: ";
	cout<<"your chosen option:";
	cin>>select;
	
	if(select==1)
		{
			e.ecost();
		}
	else if(select==2)
		{
			w.wcost();
		}
	else if(select==4)
		{
		   
		}
	
	
	
	
	

	return 0;
}
A function is a function.

1
2
3
4
5
6
7
8
9
10
11
12
#include <string>
#include <iostream>

void foo() {
  // we want to write the size of a string into std::cout here
}

int main()
{
  std::string bar = "Hello";
  foo(); // we want to see the size of bar here
}

What does it take to get what we want?
Forgot to reply.. thanks keskiverto!! i actually got it!
Topic archived. No new replies allowed.