@vlad from moscow:
|Could you explain what is the four-sided matrices? In the figure you showed I see a 3 x 3 matrix.|
What I meant was that the outline of the printed matrix should form a rectangle; the size of the matrix is irrelevant. If you look at my first post, you would observe that the elements of the first pair of matrices form a rectangle, or roughly, a square(a special form of rectangle); each of which is a four-sided polygon or quadrilateral. Notice the elements of the other pair of matrices do not all align.
|You've confused people because you are trying to do something weird -- that is, you cannot inspect or modify the way the C++ parser handles whitespace.|
I disagree with the "weird" characterization of this attempt. All I'm trying to do is format the matrix output so that all the elements align together. I can do it in function main
by individually formatting the output with the setw()
function depending on what each string literal/constant is, but that would be messy, would waste time and would defeat the adaptive quality a program should have. For instance, in main
, the statements
cout<<"A = "<<A;
would not produce the perfect rectangle of matrix elements I'm looking for without some formatting in the overloaded << operator function. That's why my first post asked for a means to pass the string literal/constant (preceding the << operator) from main
to the function
. My prior posts provide more context.
|A use case scenario is to remember that not all matrices are square. |
A 3x4 matrix != a 4x3 matrix, for example, but your assignment function seems to want to accept that.
I never implied that all matrices are square. Neither did I refer to an assignment function in my earlier posts. True, a 3x4 != 4x3 matrix; but, in maths/linear algebra texts (or even online), both have (roughly) rectangular outlines when their elements(say, integers) are printed.
|Personally, I would worry less about making C++ look pretty than making things work the C++ way: |
Well, not if you're a student and your TA or professor takes off points for shoddy result presentation! The functionality of my implementations for the +,-,* operator functions is not in question; I have successfully implemented them. However, I think program output is also important for ease of readability and appeal of presentation.
I'm sorry for the verbosity of this post; I'm just trying to make sure I present a clear picture of what I want. If C++ is that hamstrung that my task is outside its realm, then I rest my case. However, I don't think the function-controlled
output formatting I want is quixotic or unattainable. I just need a means to pass the string literal/constant from main
to the overloaded << function, besides the two parameters the function already takes.
Thanks you both for your responses. So far, this problem is getting the better of me. Alternative schemes are welcome from the forum please.