C ++ tips

Source: Internet
Author: User

2008-1-15

1. Basic Structure
Int main (INT argc, char * agrv [])

2. Basic Input and Output
Include <iostream>
Using namespace STD;
Cin>
Cout <

3. Loop Input and Output
While (! Cin. EOF ())

4. Structure Problems
If you want to call other functions in main,
Method 1: Write the function in front
Method 2: declare the function before the main function

5 shift problems
A <1; does not change the value of.

**************************************** *****

2008-1-16

1 int to string
# Include <sstream>

Stringstream SS;
SS <num;
Const char * cstring = ss. STR (). c_str ();

2. Define the array type
Typedef int sheet [2] [2];

Sheet;

A [0] [1] = 10;

***************************

2008-1-17

1 string
String can be summarized and used
Getline (CIN, string)
String: Find ()
String: substr ()
String: c_str ()
String: length ()

Char * STR = new char [N]
Cin> STR;
New

***************************************

1. Enum
{, //, Separated by numbers
// The last one is not added,
}

**************************************** ***

2008-1-21

1. When the pointer encounters an array
Use a pointer to point to an element in the array.
Int A [3] = {1, 2, 3 };
Int * temp = a + 2;

Point the pointer to an element in the array as a parameter.
Int * temp;
Fun (temp );

Void fun (int * & I) {I = a + length ;}
* & Sequence cannot be changed

Class 2 is over ";"

**************************************** ******

2008-1-22

1 encounter pointer Array
Mylink ** link;
Link = new mylink [10]; // Error
Link = new mylink * [10]; // correct

**************************************** *********

1 error c2236: Unexpected "class "...
After Enum, there are fewer semicolons.

**************************************** ***********

2008-7-25

Struct Structure

Defines a struct structure.
Struct _ Structure {int index; char * STR} structure;
There is a linked list array,
Structure *;
First, allocate the specified length of things,
A = malloc (sizeof (structure) * n );
Then you can use it directly?
A [0]. Index = 1;
A [0]. Str

Pointer to pointer
Int ** PTR;
PTR = (INT **) malloc (sizeof (int *) * 10 );

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.