C ++ implements heavy-load ostream and heavy-load ostream
#include The main note is to define the function as a friend function of the class Point outside the class. In addition, pay attention to the return OS to achieve the chain function.
Heavy Load of C ++ into ostream class
Ostream has a char * overload,Const char
C LanguageStdio. H is a function library instead of a class library.Among them, scanf printf, which we use most often, is a number of independent global functions, because C language does not support classes.
The standard input/output library iostream of C ++ is a class library that is organized in the form of classes. To use the class in this library, you must first reference the namespace: Using namespace STD;The most commonly used are CIN and cout, both of which are objects,CIN is the objec
the Ostream class defines 3 output Stream objects:cout,cerr,clog. Cerr and clog are standard error streams, the difference is:cerr not through the buffer directly to the display output information;Clog In the buffer, when the buffer is full or Endl output to the monitor. Example: Solve a two-time equation, if the formula error, with cerr flow output information. Solution : Program:#include #include using na
1 flush2 operator3 Put4 SEEKP5 TELLP6 Write1 flushRefresh the output stream2 operatorInsert operator3 PutNo formatting, inserting a character4 SEEKPMove the output stream pointer5 TELLPReturns the pointer value for the specified position in the output stream6 WriteInserts a sequence of bytes from unformattedStd::cout.write (str, 10);//maximum output of 10 characters, not including '1#include 2 3 voidMain ()4 {5 CharStr[] ="123456789ABCDEFG";6 7Std::cout.write (str,Ten);//maximum output of 10
#include The main point to note is that the function as a class point friend function, outside the class definition, in addition to pay attention to the return OS, to achieve the role of chain.Implementation of C + + overloaded Ostream
| (Bitwise OR)
The byte index of the file starts at 0. (just like an array)
We can also call the Read function and the Write function to read and write the file.The use of the file pointer position in C + +:
iOS::Beg file Header
iOS:: EndFile End
iOS::cur Current Location example:
File. seekg(0,ios::end);
int FL_SZ = file. Tellg();
File. seekg(0,ios::beg);
Common methods of e
S.
String Getline
istream Getline (istream is, string str, char delim);istream Getline (istream is, string str);
Functions of the function and
istream Istream::getline (char* s, streamsize N);istream Istream::getline (char* s, streamsize N, Char Delim);The same
istream Read (char* s, streamsize N);
Reads n characters from the input stream, or touches the file terminator but not the s last Plus '/0 ', so it's not a CString string
ostream Write (char*
; use ++;
If (-- p-> use = 0)
Delete p;
P = rhs. p;
Return * this;
}
Ostream operator
{
E. p-> print (o );
Return o;
}
Void main ()
{
Expr t = Expr ("*",
Expr ("-", Expr (5 )),
Expr ("+", Expr (3), Expr (4 )));
Cout
}
Summary
This example shows the three elements of object-oriented. The classes designed in this example have good scalability. For
////Async_client.cpp// ~~~~~~~~~~~~~~~~//an asynchronous HTTP client that is very similar to synchronization. The difference is the last point where the loop is synchronized//Copyright (c) 2003-2013 Christopher M. Kohlhoff (Chris at kohlhoff dot com)////distributed under the Boost software License, Version 1.0. (See accompanying//file license_1_0.txt or copy atHttp://www.boost.org/LICENSE_1_0.txt)//#include#include#include#includestring>#include#includeusingboost::asio::ip::tcp;//Client Clients
////Sync_client.cpp// ~~~~~~~~~~~~~~~//HTTP client, synchronizing//Copyright (c) 2003-2013 Christopher M. Kohlhoff (Chris at kohlhoff dot com)////distributed under the Boost software License, Version 1.0. (See accompanying//file license_1_0.txt or copy atHttp://www.boost.org/LICENSE_1_0.txt)//#include#include#include#includestring>#includeusingboost::asio::ip::tcp;intMainintargcChar*argv[]) { Try { if(ARGC! =3) {Std::cout"usage:sync_client "; Std::cout"
Python decorator use example and actual application example, python example
Test 1
Deco is running, but myfunc is not running
Copy codeThe Code is as follows:Def deco (func ):Print 'before func'Return func
Def myfunc ():Print 'myfunc () called'Myfunc = deco (myfunc)
Test 2
Call myfunc in the required deco to executeCopy codeThe Code is as follows:Def deco (func
/*======================================================================
A Globalmem Driver As an example of char device drivers
There are two same globalmems in this driver
This example was to introduce the function of File->private_data
The initial developer of the original code is Baohua Song
======================================================================*/
#include #include #include #include #in
Flex with C ++ getting started example
Anyone who has learned how to compile is probably familiar with Flex.Flex-fast lexical analyzer generator is defined by GNU. It means Flex is fast Lex, but is it better than att's Lex? I don't know.First, let's start with our first example. We need to count the number of lines and characters in a document. But I don't want to write the function mysel
Remember when a friend wanted his VFP program to run this way: There is no VFP main screen (_screen), the runtime directly on the desktop, a login dialog box, enter the user name and password and verify the software after the main interface, looks like the software written in VB, a very cool feeling.
The main interface of VFP software can usually be implemented in two ways: the main screen (_screen) or the top-level form (or the parent-child form). You can use the top level form to implement th
This example applies to the knowledge of the Between...and clause in the SELECT statement, referring to the SELECT statement: Select SQL command or the SQL language tutorial.
This example runs the following diagram:
This example uses the "Data 1" database "People information table", about the database is already looking at the case of VFP: sample database is
The concept of a single case pattern
A single example pattern is a design pattern in which a class has only one object instance in the entire application. Specifically, as an object creation, the singleton pattern ensures that a class has only one instance, and instantiates it itself and provides this instance to the entire system globally. Instead of creating an instance copy, it returns a reference to an instance stored within a singleton class.
C
Transferred from: http://aigo.iteye.com/blog/2301010Although the official Doc says that the event binding method is exactly the same as multi-cast usage, there are many examples on the Multi-cast forum, but the actual is different. And there is no such example on the forum. Later looked at the next Runtime/core source, the event of the binging manner as follows (attached complete steps):1, first define the custom event, in this case we define in Gamem
Example Description:1. The shelves of this example were built in 2012 for the development of real projects, and several small and medium-sized projects have been made on this shelf. There are two different versions, one for Hibernate and one for Ibatis.2. This example is a complete shelf of SSH, including basic rights management and curd examples. Rights manageme
PHP Single example mode to realize shopping cart function-php Instance tutorial complete this small function must write the need to develop good habits PHP shopping cart development requirements function is as follows 1: Shopping cart in Session 2: Single case mode to develop function: Add or delete to increase the reduction of a commodity
PHP Single example mode realization shopping cart function-php
implement; Import Sshinterface.axe; Public class Implements axe{ public stoneaxe () {} public String Chop () { // TODO auto-generated Method stub return "Cut the tree with an axe";} }Spring provides applicationcontext.xml to organize the various beans:12Beans3Xmlns= "Http://www.springframework.org/schema/beans"4Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"5xmlns:p= "http://www.springframework.org/schema/p"6Xsi:schemalocation= "Http://www.springframewo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.