0

Hi,

i have some issues with class inheritance and i do not know how to solve it, maybe someone could help me with that ?

```
//pentathlete.h
#include <iostream>
using namespace std;
template < class T >
class pentathlete {
protected :
T comp_res [ 5 ] ;
/*private:
int sum_res ;*/
public :
class error_1 { } ;
class error_2 { } ;
T sum_res ;
pentathlete ( ) {
for ( int i = 0 ; i < 5 ; i ++ ) {
comp_res [ i ] ;
}
sum_res = -1 ;
}
pentathlete ( int fir, int sec,
int thi, int fou, int fif, int fin ) {
comp_res [ 0 ] = fir ;
comp_res [ 1 ] = sec ;
comp_res [ 2 ] = thi ;
comp_res [ 3 ] = fou ;
comp_res [ 4 ] = fif ;
sum_res = fin ;
}
void input ( ) {
for ( int i = 0 ; i < 5 ; i ++ ) {
cout << "please enter " << i + 1
<< " competition results: " ;
cin >> comp_res [ i ] ;
if ( isdigit ( comp_res [ i ] ) == false ) throw error_1 ( ) ;
if ( comp_res [ i ] > 100 ) throw error_2 ( ) ;
}
}
void results ( ) {
sum_res = 0 ;
for ( int i = 0; i < 5; i ++ ) {
sum_res += comp_res [ i ] ;
}
}
void output ( ) {
cout << "Results: " << sum_res << "\n" ;
}
};
```

```
//main program file
#include <iostream>
#include <C:\MinGW\msys\1.0\home\Owner\pentathlete.h>
//
using namespace std;
//
class pentathlete_team: public pentathlete < int > {
public:
pentathlete operator + ( pentathlete sec_comp ) {
if ( sum_res < 0 ) {
results ( ) ;
}
sec_comp . results ( ) ;
return pentathlete( 0, 0, 0, 0 ,0,
sum_res + sec_comp . sum_res ) ;
}
};
int main ( ) {
//pentathlete p1, p2, p3, result ;
pentathlete_team p1, p2, p3, result ;
cout << "First pentathlete results: \n" ;
try {
p1 . input ( ) ;
}
catch ( pentathlete_team :: error_1 ) {
cout << "you entered not a number !\n" ;
cout << "bye bye\n" ;
return 0;
}
catch ( pentathlete_team :: error_2 ) {
cout << "OMG, too big result !\n"
<< "Maximum possible value:\n"
<< "100\n" << "bye bye\n" ;
}
cout << "Second pentathlete results: \n" ;
try {
p2 . input ( ) ;
}
catch ( pentathlete_team :: error_1 ) {
cout << "you entered not a number !\n" ;
cout << "bye bye\n" ;
return 0;
}
catch ( pentathlete_team :: error_2 ) {
cout << "OMG, too big result !\n"
<< "Maximum possible value:\n"
<< "100\n" << "bye bye\n" ;
}
cout << "Third pentathlete results: \n" ;
try {
p3 . input ( ) ;
}
catch ( pentathlete_team :: error_1 ) {
cout << "you entered not a number !\n" ;
cout << "bye bye\n" ;
return 0;
}
catch ( pentathlete_team :: error_2 ) {
cout << "OMG, too big result !\n"
<< "Maximum possible value:\n"
<< "100\n" << "bye bye\n" ;
return 0 ;
}
cout << "Summarum results " ;
result = p1 + p2 + p3 ;
result . output ( ) ;
return 0 ;
}
```

And the error is:

```
In function 'int main()':
66:21: error: no match for 'operator+' in 'p1.pentathlete_team::operator+(p2.pentathlete_team::<anonymous>) + p3'
```