template<typename T>
Interval<T>::Interval()
{
a = T();
b = T();
}
what does T() mean?
2. the usually used name:
1)in copy structure, I saw many examples use rhs,like classname(const classname & rhs), what does rhs refer?
2)in class private member, we usually name our variable with prefix m, what does m mean??
3.
1 2 3
char * c;
int a;
c = a = 0; // is this right?? why
1) T() means zero-initialization. It corresponds to call of the default consttructor of type T. If to return to your example if a and b would have type int we could write
a = 0;
b = 0;
Now let assume that T denotes some structure type for example struct A { char s[10[; }; and a and b are objects of this type that is a and b have declarations
T a;
T b;
that corresponds to
struct A a;
struct A b;
So we cannot write
struct A a = 0;
or
struct A b = 0;
because there is no such operations as assigning struct A to 0. So a common record T() is used that means calling of a default constructor.
If a and b are declared haveing the type int then it will look like
a = int();
b = int();
which means zero initialization. a and b will be initialized with 0.
2) rhs means right-hand side and denotes the right operand of a binary operation.
3) prefix m is abbreviation of the word member.
4) this expression c = a = 0; is incorrect. You may not an object of type int assign to a pointer. It would be correctly to write
This may be shocking, but the equals sign doesn't have hands.
In all seriousness, in the expression a=b, a is the left hand operand. This is reflected in the terms l-value, which denotes expressions that can be assigned to (can appear on the left hand side of =).