The following working code displays the smaller of two given numbers.
#include "stdafx.h"
#include <iostream>
using namespace std;
template <class T>
class Bucky {
public:
Bucky(T a, T b) {
first = a;
second = b;
}
T smaller() {
return (first<second?first:second);
}
private:
T first, second;
};
int main() {
Bucky <int>obj(69, 105);
cout << obj.smaller() << endl;
return 0;
}
I would like to derive from class 'Bucky' and create a subclass having a member function that displays "Hi There!"
Please help.
P.S. Here is my best failed attempt to create my subclass:
template <class T>
class mySubclass : public Bucky<T>
{
public:
mySubclass(T a, T b) { // error C2512: 'Bucky<T>' : no appropriate default constructor available
//first = a;
//second = b;
}
void greet() {
cout << "Hi there!";
}
};