Passing multidimensional vector to function

Hi

Dear all, i created vector of vector and passed it to function now i want to access its values within function but it display an error
error C2679: binary '+' : no operator found which takes a right-hand operand of type 'std::vector<_Ty>' (or there is no acceptable conversion)

1
2
// table 
vector < vector < int > > contingencyTable (num_table_values + 1 , vector< int > ( num_table_values + 1));

1
2
3
4
5
6
 // assigning values
contingencyTable[a][b] = (contingency_frequency_matrix.compute(vals))*test_var[0].size();

// function call

chi_seq_calculations( & contingencyTable, cardA, cardB);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
template<typename T>
void chi_seq_calculations( T * contingency_table, int cardA, int cardB)
{
   vector <int> marginal_sum_A(cardA+1, 0), marginal_sum_B(cardB+1, 0); 
   
       std::cout << "\n Table size is " << contingency_table->size();
	for (unsigned int i = 1; i <= cardA; i++) 
	{
		for (unsigned int j = 1; j <= cardB; j++)
		{
			//cout <<" \n function =" << contingency_table->size(;
			marginal_sum_A[i] = marginal_sum_A[i] + contingency_table[i][j];

		}

		std::cout<< " \n marginal sum of A at " <<i<<" is = "<< marginal_sum_A[i];
	}
	

}



All other steps are working very well even i can print the size of table vector within the function but i can not access elements. Please guide me how i can access elements of vector with in the function.

Thanks in advance

Try:
marginal_sum_A[i] = marginal_sum_A[i] + (*contingency_table)[i][j];
Thanks, now it is working.
Topic archived. No new replies allowed.