I'm getting error: no match for 'operator>>' in 'std::cin >> aTable[j]' for

#include <iostream>
using namespace std;

const int NUM_ROWS=15;
const int NUM_COLUMNS=15; 
typedef int TwoDimArray[NUM_ROWS][NUM_COLUMNS];

void printTable(int rows, int cols, TwoDimArray aTable);

int main () {
	int rows, columns;
	TwoDimArray aTable[rows][columns];
	cout<<"Enter rows and columns";
	cin>>rows>>columns;
	for (int i=0; i<rows; i++) {
		for (int j=0; j<columns; j++) 
			cin>>aTable[i][j];//this is the line I am getting this error for.
		}
    return 0;
}

I can't figure out why I am getting this error.

You are using rows and columns as the size values for the array declaration on Line 12 when they aren't initialized. This results in undefined behavior.

In addition, per Line 6, TwoDimArray is a 2-dimensional array of ints. Then, assuming that rows and columns were properly initialized, Line 12 declares a 2-dimensional array of TwoDimArray objects which results in a 4-dimensional array of ints. Since you are only dereferencing dimensions 1 and 2, the extraction operation is attempting to extract 2-dimensional arrays from your input. The extraction operator does not know how to extract an array, only a single value.

I'm assuming you don't want a 4-dimensional array. To fix that, you will have to fix your declaration on Line 12. If you do want a 4-dimensional array, you'll have to nest 2 more for loops to traverse dimensions 3 and 4.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.