PS. Have you noticed the code tags <> option? Posting formatted code looks good, like this:
1 2 3 4 5 6 7 8 9 10
void q::p(){
int o=0;
for(int i=0;i<a;i++)
{
for( int j=0; j<b; j++) o = x[0][0]; // set o=x[0][0] b times
if( o < x[i][j] ) o = x[i][j]; // if x[0][0] < x[i][undefined]
}
cout<<"o"<<o;
}
Line 37-38: j is out of scope. j goes out of scope after line 36. Compiler uses q::j instead, which is uninitialized. You might want to use {} for the for loop at line 35.
Line 11: You shouldn't be defining local variables (i,j) here.
programmer007 wrote:
You can't assign a value directly like this you have to use a constructor
Yes you can, if you're using C++14 or if the variables are static.