Home Forums C Programming Errors in Program Reply To: Errors in Program

#3250
S.Thananchayan
Participant

Ewwww thats got problems try this
 

#include 
template
class MyBook {
 B1 book1;
 B2 book2;
public:
 MyBook(B1 b1, B2 b2) : book1(b1), book2(b2)
     {  }
 template

 friend std::ostream& operator<<(std::ostream& os,
                                 const MyBook&);
};
template

std::ostream& operator<<(std::ostream& os,
                         const MyBook& bb)
{
 std::cout<<"My book has " << bb.book1 << ' ' << "pages" << std::endl;
 std::cout<<"I just tore out " << bb.book1 - bb.book2 << ' ' << "pages" << std::endl;
 std::cout<<"My book now has " << bb.book2 << ' ' << "pages" << std::endl;
 return os;
}
int main()
{
 int a = 970;
 int b = 965;
 MyBook my_twothings(a, b);
 std::cout << my_twothings << std::endl;
 return 0;
}