If you are n't cookie, please skip it ... Thanks
from now on, I get two methods or ways to use it:
cin.get(name,ArSize).get()
cin.get(ch);
It's really confuse me right now. I Know C language, the single arguments tha's not allowed in C-style.
There is a explation about it, which is quoted from the C++ primer plus (The Fifth Edition)
Once again it is time for those of you familiar with C to get excited or confused. In C if a function takes a pointer-to-char and an int as arguments, you can't successfully use the same function with a single argument of a different type. But you can do so in C++ because the language supports an OOP feature called function overloading. Function overloading allows you to create different functions that have the same name, provided that they have different argument lists. If, for example, you use cin.get(name, ArSize) in C++, the compiler finds the version of cin.get() that uses a chr* and an int as arguments. But if you use cin.get(ch), the compiler fetches the version that uses a single type char argument. And if the code provides no arguments, the compiler uses the version of cin.get() that takes no argumetns. Function overloading enables you to use the same name for related functions that perform the same basic task in different ways or for different types. This is another topic awaiting you in Chapter 8. Meanwhile, you can get accustomed to function overloading by using the get() examples that come with the istream class. To distinguish between the different function versions, we'll include the argument list when referring to them. Thus, cin.get() means the version that takes no arguments, and cin.get(char) means the version that takes one argument...
......
the OOP features: Function overloading....
Quoted from the C++ primer Plus
cin.get(ch) Versus cin.get()
Property | cin.get(ch) | ch=cin.get() |
Method for conveying input character | Assign to argument ch | Use function return value to assign to ch |
Function return value for character input | A class istream object(true after bool conversion) | Code for character as type int value |
Function return value at EOF | A class istream object(false after bool conversion) | EOF |
cin.get(ch1).get(ch2);
This works because the function call cin.get(ch1) returns the cin object, which then acts as the object to which get(ch2) is attached.
Probably the main use for the get() form is to let you make quick-and-dirty conversions from the getchar() and putchar() functions of stdio.h to the cin.get() and cout.put() methods of iostream. You just replace one header file with the other and globally replace getchar() and putchar() with their act-alike method equivalents. (If the old code uses a type int variable for input, you have to make further adjstments if your implementation has multiple prototypes for put().)