相关代码 |
|
#include #include using namespace std; template T Max(A a, B b); template class CTriangle { public: CTriangle(T a, T b, T c); T area(); private: T m_a, m_b, m_c; }; template CTriangle::CTriangle(T a, T b, T c): m_a(a), m_b(b), m_c(c) { return; } template T CTriangle::area() { T p; p =(m_a+ m_b+ m_c)/2; return sqrt(p*(p - m_a)*(p - m_b)*(p - m_c)); } void main() { CTriangle myObj(3.0, 4.0, 5.0); cout } template T Max(A a, B b) { return (a>b)?a:b; }
相关资源 |
|