-1

Okay so I'm trying to understand what the int i(row) and the j(col) means in this set of code, does it set i to the value in row?

for( int i(row); i < row + height; ++i )
{
    // Cycle through cols
    for( int j(col); j < col + width; ++j )
    {
        // Change the value at position ( i, j ) to the fillChar
        board[i][j] = fillChar;
    }
}
poppy
  • 5
  • 1
  • 2

1 Answers1

1

non-class/struct types in C++ (such the intrinsic/"primitive" types int, long, etc) do not have constructors, but they do have an initialization syntax which looks the same as a constructor call.

As an example, calling a class-type's constructor looks like this:

my_class myClassInstance( myClassConstructorArgument );

Similarly, using int's initializer looks like this:

int myInt( myInitialValue );

So in your case, for( int i(row); ... is the same as for( int i = row; ....

There is a third syntax that uses curly braces too:

int x = 1;
int y(2);
int z{3};

cout << x << " " << y << " " << z << endl;

gives the output 1 2 3.

Dai
  • 141,631
  • 28
  • 261
  • 374