本文整理汇总了C++中Array2D::getRow方法的典型用法代码示例。如果您正苦于以下问题:C++ Array2D::getRow方法的具体用法?C++ Array2D::getRow怎么用?C++ Array2D::getRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array2D
的用法示例。
在下文中一共展示了Array2D::getRow方法的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);
}
}
}
示例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;
}
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例6:
Array2D<T>::Array2D(const Array2D<T> ©) : m_array(copy.getRow() * copy.getColumn()), m_row(copy.getRow()), m_col(copy.getColumn())
{
m_array = copy.m_array;
}