当前位置: 首页>>代码示例>>C++>>正文


C++ Array2D::getColumn方法代码示例

本文整理汇总了C++中Array2D::getColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ Array2D::getColumn方法的具体用法?C++ Array2D::getColumn怎么用?C++ Array2D::getColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Array2D的用法示例。


在下文中一共展示了Array2D::getColumn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initializeArrayStrings

void initializeArrayStrings(Array2D<T> &boo)
{
	for (int i = 0; i < boo.getRow(); i++)
	{
		for (int j = 0; j < boo.getColumn(); j++)
		{
			boo[i][j] = to_string(i + j);
		}
	}
}
开发者ID:Roastern,项目名称:School-Projects,代码行数:10,代码来源:main.cpp

示例2: initializeArrayInts

void initializeArrayInts(Array2D<T> &boo)
{
	for (int i = 0; i < boo.getRow(); i++)
	{
		for (int j = 0; j < boo.getColumn(); j++)
		{
			boo[i][j] = i + j;
		}
	}
}
开发者ID:Roastern,项目名称:School-Projects,代码行数:10,代码来源:main.cpp

示例3: printArray

void printArray(const Array2D<T> &boo)
{
	for (int i = 0; i < boo.getRow(); i++)
	{
		for (int j = 0; j < boo.getColumn(); j++)
		{
			cout << boo[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
}
开发者ID:Roastern,项目名称:School-Projects,代码行数:12,代码来源:main.cpp

示例4: print

void print(Array2D<T> myArray)
{
	for (int i = 0; i < myArray.getRow(); i++)
	{
		for (int j = 0; j < myArray.getColumn(); j++)
		{
			cout << myArray.Select(i, j) << " ";
		}

		cout << endl;
	}
}
开发者ID:patrickcarlson,项目名称:CST-211,代码行数:12,代码来源:Tester.cpp

示例5: testInts

void testInts()
{
	cout << "Testing with a simple data type: integers" << endl;
	cout << "First, we'll test the constructors:" << endl;

	cout << "Testing the default constructor, row and column should = 0)" << endl;
	Array2D<int> blob;
	cout << "Rows: " << blob.getRow() << " Columns: " << blob.getColumn() << endl << endl;

	cout << "Testing the constructor with both rows and columns defined at initialization: " << endl;
	Array2D<int> boo(3, 5);
	cout << "Rows: " << boo.getRow() << " Columns: " << boo.getColumn() << endl << endl;

	cout << "Testing subscript operators with valid input: " << endl;
	initializeArrayInts(boo);
	printArray(boo);

	cout << "Testing copy constructor: " << endl;
	Array2D<int> bo(boo);
	cout << "Rows: " << bo.getRow() << " Columns: " << bo.getColumn() << endl << endl;
	printArray(bo);

	cout << "Testing the assignment operator: " << endl;
	blob = bo;
	cout << "Rows: " << blob.getRow() << " Columns: " << blob.getColumn() << endl << endl;
	printArray(blob);

	cout << "Now testing mutator functions for both rows and columns: " << endl << endl;
	cout << "First with adding rows: " << endl;
	boo.setRow(6);
	cout << "Rows: " << boo.getRow() << " Columns: " << boo.getColumn() << endl << endl;
	initializeArrayInts(boo);
	printArray(boo);

	cout << "Now deleting rows: " << endl;
	boo.setRow(3);
	cout << "Rows: " << boo.getRow() << " Columns: " << boo.getColumn() << endl << endl;
	printArray(boo);

	cout << "Now passing an invalid row length: " << endl;
	try
	{
		boo.setRow(-1);
	}
	catch (Exception &except)
	{
		cout << except << endl << endl;
	}

	cout << "Now adding columns (maintains data position in current rows/columns): " << endl;
	boo.setColumn(7);
	cout << "Rows: " << boo.getRow() << " Columns: " << boo.getColumn() << endl << endl;
	printArray(boo);

	cout << "Now deleting columns (maintains data position in current rows/columns which are being kept): " << endl;
	boo.setColumn(5);
	cout << "Rows: " << boo.getRow() << " Columns: " << boo.getColumn() << endl << endl;
	printArray(boo);

	cout << "Now passing invalid value for column: " << endl;
	try
	{
		boo.setColumn(-1);
	}
	catch (Exception &except)
	{
		cout << except << endl << endl;
	}
	cout << "Rows: " << boo.getRow() << " Columns: " << boo.getColumn() << endl << endl;
	printArray(boo);

	cout << "Testing subscipt operator access on a const object: " << endl;
	const Array2D<int> const_boo(boo);
	printArray(const_boo);

}
开发者ID:Roastern,项目名称:School-Projects,代码行数:76,代码来源:main.cpp

示例6:

Array2D<T>::Array2D(const Array2D<T> &copy) : m_array(copy.getRow() * copy.getColumn()), m_row(copy.getRow()), m_col(copy.getColumn())
{
	m_array = copy.m_array;
}
开发者ID:Roastern,项目名称:School-Projects,代码行数:4,代码来源:Array2D.cpp


注:本文中的Array2D::getColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。