Well, the week I tried to use some class things.
Following is parts of my exercising codes.
- Definig my class named Time
Note that CNT was a static member of this class to count the number of
Instances created.
- Constructors & Overloading
As can see, the 2nd one is a Copy Constructor. And since both of
The constructors has same name but different parameters, they
is also kind of overloading.
- Pass by Values OR References
When passing parameters, ref was needed in front of value types-pass by
Reference While, it's not necessary if your pass an object (the output would be post
Later).
- Other Member Functions of Class
These functions is used to display the contents of the instances.
----------so Much about the time class---------
Now, let me write some codes to test the time class.
Create objects T1 and T2(with copy constructor)
I first invoked getbirthtime, passing an object, then invoked getbirthtime
Secondly, passing value types by reference.
---------------so Much for Test---------------
In the end, let's has a look at our Output ...
Pay attention to the change of the CNT (static member);
Also, we'll find the amazing effect of passing by reference.
-----------END & to Be continued-----------^ ^
3.0 Basic Usage of Class