Solved C++ % " ?
-
Hope you cannot overload ';' That would probably cause the ultimate confusion.
-
@koahnig
;
is not an operator. I believe it is a "statement separator" (whereas Pascal had it as a "statement terminator"... or is it the other way round?). -
Thanks for clarification, I am so happy about that ;)
However, with the ancient FORTRAN they discussed a COME FROM statement
Therefore, you never know what somebody will come up with. At least FORTRAN did not require a "statement separator" nor a "statement terminator". The logical end of aline was the end of the punching card after 80 chars respectively you had to subtract 8 digits for the line number. -
-
Though you should better define
QT_USE_QSTRINGBUILDER
and simply use+
everywhere instead of%
-
@Konstantin-Tokarev said in C++ % " ?:
Though you should better define
QT_USE_QSTRINGBUILDER
and simply use+
everywhere instead of%
Ooohhh, the plot thickens...!
-
@JonB Qt has ome confusing operaters as well.
for example take QVectors +=
QVector<T> QVector::operator+(const QVector<T> &other) const
I would asume this to be Vector addtion
QVector v1{a,b,c}; QVector v2{d,e,f}; //What one would expect v1 += v2; -> {a+d, b+e, c+f} //what one gets v1 +=v2; _> {a,b,c,d,e,f}
I mean, this technically makes sense. QVector is to generic to have this operation, thats why there is QVector2D, 3D, 4D etc
It still confused me the first time I used it. I did not expect += to be equal to .append() or <<;
In this paticular example I have would prefere a missing += operator :-).
-
@J.Hilk To be honest I would be rather confused if it would do
v1 += v2; -> {a+d, b+e, c+f}
A vector is not a number or something, it is a container. Or is it because it is called "vector" and you expect it to behave like a vector in math? :-)
-
@J.Hilk To be honest I would be rather confused if it would do
v1 += v2; -> {a+d, b+e, c+f}
A vector is not a number or something, it is a container. Or is it because it is called "vector" and you expect it to behave like a vector in math? :-)
That is debatable and apparently dependent on your background. The foprm you find confusing would be the most logical version for me.
-
@jsulm I used to use only QList as a container, and one day I needed to do Vector operations. In my youthfull naiveté I assumed QVector = linear algebra vector.
I learned quickly thats not the case 🤷Ever since, I prefere using QVector over QList.😉
-
-
In the mathematical sense it is alwways a vector, but in spaces with different dimensions. All operators are bascially identical, therefore "real" engineers can accept this. Personally I doubt that the definition of basically changing the space dimension during an addition is conform with pure mathematics. On the other hand you never know what they think/thoght in those areas ;)
-
I'm actually wondering why it is called vector?
In linear (and higher) algebra, a vector is an ordered set, or more precisely (and formally speaking) - it is the element of the linear space defined over a field; usually the field of real or complex numbers. Very similar to what you call a vector in programming.
It's just convenience that in Qt you have the
+
defined to mean merging of two arrays, and not the mathematical operation, as you don't regularly require the mathematical properties of a vector; it's just not so useful in everyday life. -
@JonB Qt has ome confusing operaters as well.
for example take QVectors +=
QVector<T> QVector::operator+(const QVector<T> &other) const
I would asume this to be Vector addtion
QVector v1{a,b,c}; QVector v2{d,e,f}; //What one would expect v1 += v2; -> {a+d, b+e, c+f} //what one gets v1 +=v2; _> {a,b,c,d,e,f}
I mean, this technically makes sense. QVector is to generic to have this operation, thats why there is QVector2D, 3D, 4D etc
It still confused me the first time I used it. I did not expect += to be equal to .append() or <<;
In this paticular example I have would prefere a missing += operator :-).
Wait till you try
+
or+=
onQJsonArray
;)QJsonArray a1{1, 2, 3}; QJsonArray a2{4, 5, 6}; a1 += a2; // a1 now has 4 elements: 3 numbers and 1 array
-