Hi, I am trying to write an address book. The problem is: in my class declaration I declared a mutator.
In the implementation, I am asking the user to enter his address, city, state and zip.
So my prototype void set_add(string, string, string, int).
In other words I am trying to set the address, city, state, and zip variables to the one entered by the user. To implement this I am using reference.
But no matter what I put in as arguments while calling from main, I keep getting the error: variable 'variable' not declared.
Here is my code for clarity:
/******************Header**************************/
#ifndef addressType_H
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class addressType
{
private:
string St_address;
string city, state;
int Zip;
public:
addressType(string, string, string, int);//default constructor;
void show_add();//accessor
void set_add(string&, string&, string&, int&);//mutator
};
#endif
/************Implementation*********************/
#include "addressType.h"
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
addressType::addressType(string street, string cit, string st, int zip)
{
street = "9803 Summer Breeze Dr.";
St_address = street;
cit = "Pearland";
city = cit;
st = "Tx";
state = st;
zip = 77584;
Zip = zip;
}
void addressType::show_add()
{
cout<<St_address<<endl;
cout<<city<<","<<state<<endl;
cout<<Zip<<endl;
return;
}
void addressType::set_add(string &street, string &cit, string &st, int &zip)
{
cout<<"Enter street address."<<endl;
cin>>street;
cout<<"Enter your city."<<endl;
cin>>cit;
cout<<"Enter your state."<<endl;
cin>>st;
cout<<"Enter the zip code."<<endl;
cin>>zip;
return;
}
/**********************main()******************/
#include "addressType.h"
#include<iostream>
#include<string>
using namespace std;
int main()
{
addressType Avi("9803 Summer Breeze", "Pearland", "Tx", 77584);
Avi.show_add();
Avi.set_add(St_address, city, state, Zip);//what will be my arguments here that would set the values to the one that user inputs?
return 0;
}
Thanks.