i've defined the next templated interface which has a cin and cout friend functions:
#ifndef IPRINTABLE_H
#define IPRINTABLE_H
#include <iostream>
using namespace std;
template <class T>
class IPrintable
{
public:
virtual friend istream &operator>>(istream&, T&) = 0;
virtual friend ostream &operator<<(ostream&, const T&) = 0;
};
#endif
i tried implanting these functions in a derived class like this:
#ifndef DATE_H
#define DATE_H
#include "IPrintable.h"
class Date : public IPrintable<Date>
{
public:
Date();
Date(int, int, int);
~Date();
void setDay(const int);
void setMonth(const int);
void setYear(const int);
friend istream &operator>>(istream&, Date&);
friend ostream &operator<<(ostream&, const Date&);
private:
int day;
int month;
int year;
};
#endif
but all i got was a bunch of errors:
i tried searching an answer in the internet, but found nothing helpful, and that's why i'm asking for your help with solving this issue.
i'm new to this concept of inheritance using friend functions in templated interface, so there's a big chance i'm doing something wrong here.
thank you in advance
P.S. how can i solve this problem: