Ask help analyze the source code! Experts invited!

Category: C/C++ -> C Author: WJYZWX Date: 2007-01-22 23:16:15
2007-01-22 23:16:15
DBBayCltn * BayCltn = DBBay :: selDBByVslCl (vsl_cl_n);
DBBayCltnIter bayiter (* BayCltn);
while (+ + bayiter) {
stdbaytobaydict-> insertKeyAndValue (new RWCString (bayiter.key () -> stdBayN ()),
new RWCString (bayiter.key () -> bayN ()));

bayiter is an object of class DBBayCltnIter do? If yes, + + bayiter explain how, if bayiter is not an object of class, how do you explain this code do?
2007-01-22 23:38:09
is that class An object

+ + because overloaded operator.
2007-01-22 23:59:30
I am not familiar with c + +, but now I need to understand using c + + to write the source code.
Since bayiter is an object, how can + + bayiter that?
overloaded operators What is the concept?
2007-01-23 00:29:52
in C + + in + + is the increment operator, it can only be used integer variable or pointer variable, the role is to increase the value of a variable, but in order to increase the flexibility of the language, C + + allows existing operators be overloaded to adapt to a variety of custom type. That is, for a certain type of overload (generally refers to an object class) again "definition" of an existing operator. The example that is an object for DBBayCltnIter redefine the + + operator, the code should have DBBayCltnIter & operator + + (); or friend DBBayCltnIter & operator + + (DBBayCltnIter &); function prototype, you See the corresponding function definition can know + + bayiter operation of the process. It should be noted that operator overloading does not change the operator for built-in types (such as int, float, char, etc.) the mode of action, in the above example you use
int f = 0;
+ + f; / / + + a value after a 1
Whether you against a particular class overloads the + + operator, on a the + + operator + + is still under the old definition.

2007-01-23 01:04:56
Thank you, old chap! ~
I am saying is not well understood:

you mentioned:

Whether you against a particular class overloads the + + operator, for a the + + operator + + is still under the old definition.

then for DBBayCltnIter since it overloads the + + operator, then bayiter the + + operator + +, based upon the original definition of how to understand.

In this code executed + + bayiter, probably after the results look like.
2007-01-23 01:39:15
Sorry, wrong, a should be replaced by f. f is the int type, I mean even if you DBBayCltnIter overloaded + operator, then the behavior still depends on the specific operation type of the variable you want to operate, if it is DBBayCltnIter object, then use the newly defined + + for operation; If you want to operate the variable is of type int or a pointer, then no matter whether you are in DBBayCltnIter overloaded + +, C + + is still used internally defined by 1 operation.