The format of CIN >> is to read the data before the blank delimiter from the buffer, i.e. the data before the space
Getline (cin, parameters), which can be read into the data before the carriage return.
C + + is a strong type, reflected in, if you need to enter an integer type cin>>n, but you enter a character a, then he will return a negative number, and N is assigned 0;
When the string is too long, you can say the following:
Const char* CHARSTR = "This is one very long string"//Direct carriage return line
"So I'll continue it on the next line";
An object of type string that can absorb a string, and whose. Length () returns the length of the object string.
Ostringstream Strbuf; You can absorb strings and integer values, or you can say, input data from the output to the screen into this object, and use Strbuf.str (), character the data in this object, and then use it for string output.
You can export to a file using the following:
Ofstream Outf;
Outf.open ("MyData");
Outf << Strval; Strval is a String type
Outf.close ();
When reading data from a file, there are two actions
Ifstream inf;
INF >> newstr >> lucky2; The role of this, intuitively speaking, is to use the string in the file as a split unit, after each string of data will be used at a time by the INF >> newstr >> into the variable, regardless of the type is right, and can only start from the beginning, cannot specify the number of data sent.
The following are output by line:
Ifstream inf;
String Newstr;
Inf.open ("MyData");
while (not inf.eof ()) {
Getline (INF,NEWSTR);
cout << newstr <<endl;
}
Inf.close ();
Pointer sizes are integral types, regardless of their type.
With regard to static, when declaring in a class, using static is equivalent to a global declaration, which is not validated by practice, but should not be static when defining related class members, because doing so will limit the definition to the current file.
Overloaded ' = ': fraction& operator= (...) {}
Transform constructors, halo-sound, intuitively, there is this constructor, which has multiple parameters, but some of which are already assigned in the parameter list. So it is not necessary to give all arguments to the constructor after it is called, and to provide a parameter that is not assigned. Is that the number of arguments in the call is less than the number of formal parameters.
After the function declaration, the const is also considered part of the function signature, that is, void demo (int) and void demo (int) const
is two overloaded functions, not conflicting functions, so how does the compiler distinguish between these two functions?
Q: When calling, the function name plus C for the call with the const suffix, example: CDemo (int x) is a call to the latter, and no C is a call to the former.
Decimal constants are double-type by default in C + +. For example, 2.3 is a double type.
This article is from the "Developing_rookie" blog, make sure to keep this source http://8942041.blog.51cto.com/8932041/1589805
C++learning_at_2014/12/14