Finding the name of the object parameter

This is a discussion on Finding the name of the object parameter within the C++ Programming forums, part of the General Programming Boards category; I am writing a class for matrices by the name of Matrix. I have an empty constructor Matrix() where I ...

Finding the name of the object parameter

I am writing a class for matrices by the name of Matrix. I have an empty constructor Matrix() where I initialize the dimensions (rows and columns) of the matrix to zero. This is because I would like the user in the main program to set the dimensions through another overloaded constructor or other explicit means. However, in case the user fails to set the dimensions of the object of class Matrix, the dimensions will remain at 0. I have written the following function that checks for undefined dimensions that works:

A better idea is to place an ASSERT instead.
You don't want the user to see that, do you? With an ASSERT, then program will break when the condition is met and you can take a look at the stack to see in what object the problem occurred.

A better idea is to place an ASSERT instead.
You don't want the user to see that, do you? With an ASSERT, then program will break when the condition is met and you can take a look at the stack to see in what object the problem occurred.

I think ASSERT() is Windows specific.
The standard assert() is defined in <cassert>

Of course, there's no need to roll your own (probably broken) assert when there's a perfectly good assert (and there's no need for a function dimension_check as the condition to assert is very simple).