typeclass.cpp
来自「这是我利用STL写的ISODATA分类算法」· C++ 代码 · 共 61 行
CPP
61 行
// 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;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?