![]() |
#2
yuccn2011-11-04 20:51
|

#include <iostream>
#include <cstring>
using namespace std;
class Books
{
private:
float Price;
string Author;
public:
Books(float price, string author);
void ShowInfo();
Books& operator =(const Books &bookname);
};
Books& Books::operator = (const Books &bookname)
{
if (&bookname == this)
return *this;
else
{
Books temp(bookname.Price, bookname.Author);
return temp;
}
}
Books::Books(float price, string author)
{
Price = price;
Author = author;
}
void Books::ShowInfo()
{
cout << "Book Price" << '\t' << Price << endl;
cout << "Book Author" << '\t' << Author << endl;
}
int main()
{
Books APEU(67, "Bob");
APEU.ShowInfo();
return 0;
}