I have a variable in my "book.cpp" file named title. I want to pass this variable over to my "page.cpp" file so I can use it to output a page. How do I go about doing this? Here is a portion of my book.cpp file for getting the string:
Code:
string Book::getTitle(string title)
{
size_t title_start;
title_start = title.find("Title:");
if (title_start == title.npos)
return "";
title = title.substr(title_start+7);
return title;
}
and here is the book.h file class:
Code:
class Book {
ifstream file;
string title;
public:
string getTitle(string title);
Book(istream& in);
bool open(istream& in);
};
and I am trying to get it over to my page.cpp file:
Code:
void Page::output(ofstream& out) const
{
string title;
out.open("Page0001.html");
out << "<title>" << title << "</title>" << endl;
out.close();
}
with this page.h file class:
Code:
class Page {
int lines;
int pagenumber;
ifstream file;
ofstream out;
vector<string> text;
public:
Page(istream& in);
void setPageNum(int pageNum);
void addLine(string line);
void output(ofstream& out) const;
int getLines() const;
int getPageNum() const;
};
Any help is appreciated!