Hi I am writing a address book program that is giving a run time error. Please if someone can compile and check this error, and then explain/ show me how can I resolve it. I am pasting my code in parts here as well as attaching the files.

Also please someone explain me, how can I print the user input address in the main(). I mean what should my argument be for the print_add() when I call it in main().

I really appreciate your help.
Thanks.

/**********Header file*****************/
#ifndef addressType_H


#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

class addressType
{
private:
	string St_address;
	string city, state;
	int Zip;

public:
	string  print_add(string, string, string, int);
	void get_add();
	void set_add(string, string, string, int);
	addressType();
	~addressType();
};
#endif

/***********************Implementation section*********/

#include "addressType.h"
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;


addressType::addressType()
{
     St_address = "9803 Summer Breeze Dr.";
	 city = "Pearland";
	  state = "Tx";
	  Zip = 77584;

}


void addressType::get_add()
{

	cout<<"Enter your street address."<<endl;
	cin>> St_address;

	cout<<"Enter your city."<<endl;
	cin>> city;

	cout<<"Enter your state."<<endl;
	cin>> state;

	cout<<"Enter your zip code."<<endl;
	cin>> Zip;
	
	set_add(St_address, city, state, Zip);

	return ;
}

void addressType::set_add(string street, string cit, string st, int zip)
{

   	St_address = street;
	city = cit;
	state = st;
	Zip = zip;

	print_add(St_address, city, state, Zip);

	return;

}

string addressType::print_add(string str, string Cit, string St, int Z)
{
	cout<<"Address: "<<endl;
	cout<< Cit <<","<<St<<endl;
	cout<<"Zip: "<<Z<<endl;

	return 0;

}

addressType::~addressType()
{}

/**************Test program********************/
// Address Directory.cpp : Defines the entry point for the console application.
//
// add_Book.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"

#include "addressType.h"
#include<iostream>
#include<string>
using namespace std;

int main()
{
	addressType Avi;
	Avi.get_add();
	Avi.print_add("9803 Summer Breeze", "Pearland", "Tx", 77584);


	return 0;
}

Solved it.

I was able to solve the error.
The problem was with the return type of the print_add() function. I changed it from string to void and the error got resolved.

But this leads me to a question, which I will ask in a new thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.