I have a code here that needs to return a string from a function, but the compiler continues to tell me an error saying that "overloaded function differs only by return type from 'int Bible::getName(void)'". How can I fix this?
Here is my code:
// Joseph Yong
// CSC2430
// Homework 6
//Implementation File
/*----------------------------------------------------------------*/
#include <iostream>
#include <string>
#include "Header1.h"
;using namespace std;
//Constructors
Bible::Bible()
{
name = "";
chapter = 0;
verse = 0;
testament = "";
text = "";
}
Bible::Bible(string nam, int chapt, int vers, string testa, string txt) //Initialize to any size
{
name = nam;
chapter = chapt;
verse = vers;
testament = testa;
text = txt;
}
//Mutators
void Bible::setName(string nam)
{
name = nam; //Change the string value of name
}
void Bible::setChapter(int chapt)
{
chapter = chapt; //Change the int value of chapter
}
void Bible::setVerse(int vers)
{
verse = vers; //Change the int value of verse
}
void Bible::setTestament(string testa)
{
testament = testa; //Change the string value of testament
}
void Bible::setText(string txt)
{
text = txt; //Change the string value of text
}
void Bible::setSetup1(string nam, int chapt, int vers, string testa)
{
name = nam;
chapter = chapt; //Changes all data members
verse = vers;
testament = testa;
}
void Bible::setInput()
{
cout << "Enter the book name, chapter, and verse: ";
cin >> name >> chapter >> verse >> endl;
cout << "Enter in the testament: ";
cin >> testament >> endl;
cout << "Enter in the contents of the verse: ";
cin >> text >> endl;
}
//Accessors
string Bible::getName()
{
return name;
}
int Bible::getChapter()
{
return chapter;
}
int Bible::getVerse()
{
return verse;
}
string Bible::getTestament(string testament)
{
return testament;
}
string Bible::getText(string text)
{
return text;
}
And here is my header code:
// Joseph Yong
// CSC2430
// Homework_6
//Header File
/*--------------------------------------------------------------------------*/
#ifndef HEADER
#define HEADER
#include <iostream>
#include <string>
using namespace std;
class Bible
{
public:
//Constructors
Bible();
Bible(string nam, int chapt, int vers, string testa, string txt);
//Mutators
void setName(string nam);
void setChapter(int chapt);
void setVerse(int vers);
void setTestament(string testa);
void setText(string txt);
void setSetup1(string nam, int chapt, int vers, string testa);
void setInput();
//Accessors
string getName();
int getChapter();
int getVerse();
string getTestament();
string getText();
//Output
void write1();
void write2();
private:
string name, testament, text, input;
int chapter, verse;
};
#endif