- Optional Function/Method Parameters:
- Those are the parameters that have default values, and are always put at the end of the parameters list. What I learned was not to define a default parameter twice (in the declaration and in the implementation), as it will not compile.
- Subscripting: Overloading the [] Operator:
- Overload it twice:
- Once with a return value of a reference type, which causes it be an I-value, allowing subscripted expressions on either side of the assignment operators:
- Vect& Vect::operator[](x_enum);
- To be used as either:
- V[x] = 5.0f;
- Or V[x] = V[y];
- The second version of it is intended to be used by a constant object of the class it is overloaded for:
- const Vect Vect::operator[](x_enum) const;
- Overloading Unary Operators ( +, -, ++, -- ):
- Can be overloaded by a global function made as a friend for the class:
- Vect operator+(Vect& v);
- Or as instance method, like below:
- Vect Vect::operator+();
- Nameless Unions: to reduce typing.
Wonderful class so far! :)
No comments:
Post a Comment