www.pudn.com > ISODATA.rar > TypeClass.cpp


// TypeClass.cpp: implementation of the CTypeClass class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "TypeClass.h" 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
CTypeClass::CTypeClass() 
{ 
	m_pdCenter = NULL; 
	m_pdVariance = NULL; 
} 
 
CTypeClass::CTypeClass(int iPattDim) 
{ 
	m_iPattDim = iPattDim; 
	m_pdCenter = NULL; 
	m_pdVariance = NULL; 
	m_pdCenter = new double[m_iPattDim];//Class Center 
	memset(m_pdCenter, 0, sizeof(double)*m_iPattDim); 
	m_pdVariance = new double[m_iPattDim];//Class Variance; 
	memset(m_pdVariance, 0, sizeof(double)*m_iPattDim); 
 
} 
 
CTypeClass::~CTypeClass() 
{ 
	delete[] m_pdVariance; 
	m_pdVariance = NULL; 
	delete[] m_pdCenter; 
	m_pdCenter = NULL; 
} 
	 
CTypeClass::CTypeClass(const CTypeClass& CopyClass) 
{ 
	m_iPattDim = CopyClass.m_iPattDim; 
 
	m_pdCenter = new double[m_iPattDim];//Class Center 
	m_pdVariance = new double[m_iPattDim];//Class Variance; 
	memcpy(m_pdCenter, CopyClass.m_pdCenter, sizeof(double)*m_iPattDim); 
	memcpy(m_pdVariance, CopyClass.m_pdVariance, sizeof(double)*m_iPattDim); 
 
} 
CTypeClass CTypeClass::operator =(const CTypeClass& RClass) 
{ 
	m_iPattDim = RClass.m_iPattDim; 
	if(m_pdCenter != NULL) 
		delete[] m_pdCenter; 
	m_pdCenter = new double[m_iPattDim];//Class Center 
	if(m_pdVariance != NULL) 
		delete[] m_pdVariance; 
	m_pdVariance = new double[m_iPattDim];//Class Variance; 
	memcpy(m_pdCenter, RClass.m_pdCenter, sizeof(double)*m_iPattDim); 
	memcpy(m_pdVariance, RClass.m_pdVariance, sizeof(double)*m_iPattDim); 
	return *this; 
 
}