C++模板类继承模板类

#include 
using namespace std;

template 
class Shape {
protected:
    type x, y, z, width, height;
private:

public:
    virtual ~Shape(){
    } //一定要用{}实现!!
    virtual void draw() {
        cout  << "yes" << endl;
    }
};

template 
class Triangle:public Shape {
private:
public:
    Triangle();
    Triangle(T, T, T);
    ~Triangle(){}; //一定要用{}实现!!
    void draw();
};

template 
void Triangle::draw() {
    cout << "test"<< endl;
}
template 
Triangle::Triangle(T a, T b, T c) {
    this->x = a;
    this->y = b;
    this->z = c;
}

你可能感兴趣的:(C++模板类继承模板类)