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
#include <iostream>//i/o
#include <cmath>//math expressions
#include <iomanip>//i/o manipulations
#include <string>//string values
#include <fstream>//to read from a file
constdouble waterrate=108.01198630; //php per cu.m
constdouble elecrate=8.1081729;//php per kWh
usingnamespace 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();
}
elseif(select==2)
{
w.wcost();
}
elseif(select==4)
{
}
return 0;
}
#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
}