rowvalues.cpp

来自「Vc.Net入门与提高源码」· C++ 代码 · 共 70 行

CPP
70
字号
// File: RowValues.cpp
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Classes Reference and related electronic
// documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft C++ Libraries products.

#include "Stdafx.h"
#include "RowValues.h"

RowValues::RowValues() : CAtlArray<ColumnValues>()	
{
	Trace::TraceMsg("RowValues constructor");
}

RowValues::RowValues(const RowValues& c)
{
	// do a deep copy
	Trace::TraceMsg("RowValues copy constructor");
			
	int num = c.GetCount();
	
	for (int i = 0; i < num; i++)
	{						
		Add(c[i]);
	}		
}

RowValues::~RowValues()
{
	Trace::TraceMsg("RowValues destructor");		
	RemoveAll();
}

const ColumnValues& RowValues::GetRowValue(int index) const
{				
	return GetAt(index);		
}

void RowValues::AddRowValue(const ColumnValues& columnValues)
{		
	Add(columnValues);		
}

int RowValues::GetNumRows() const
{
	return GetCount();
}

void RowValues::Reset()
{
	RemoveAll();
}

// need to override = operator to make a deep copy
RowValues& RowValues::operator=(const RowValues& p)
{
	Trace::TraceMsg("RowValue = operator");

	RemoveAll();
	int num = p.GetCount();
	for (int i = 0; i < num; i++)
	{
		Add(p[i]);
	}

	return (*this);
}	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?