编程实例

源代码在线查看: mytemplate.cpp

软件大小: 2067 K
上传用户: KMPlayer33
关键词: 编程实例
下载地址: 免注册下载 普通下载 VIP

相关代码

				#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;
				}			

相关资源