I am working on a general Class for a problem of mine and I ran into a problem. In my setData function, I am supposed to set it up so that it takes a default value of 4.0 in its parameter list, and if a negative value is passed to the function, the side of the square is set to the absolute value of this negative value. If someone could possibly help me that would it be great thanks!! Here is what I have so far:
Are you getting any compiler errors? If yes, what are they?
Just from what you've said, you properly implement default arguements in your setData() functions, although I have no idea why you would want a default argument for a mutator method.
If you want the absolute value, just check to see if the number is negative, and if it is just multiply it by -1.
The compiler error at this point is ""error C2572: 'Square::setData' : redefinition of default parameter : parameter 1"". I have no idea why I am getting this error though.