1. cin.peek() cin.get() (LYP同学的方法)
int peek();
Peek next character
Returns the next character in the input sequence, without extracting it: The character is left as the next character to be extracted from the stream.
参考:http://www.cplusplus.com/reference/istream/istream/peek/
获取输入流中下一个输入的字符,但是不会提取它,这个字符依然在输入流中。
std::istream::get
single character (1) | int get();
istream& get (char& c);
|
---|---|
c-string (2) | istream& get (char* s, streamsize n);
istream& get (char* s, streamsize n, char delim);
|
stream buffer (3) | istream& get (streambuf& sb);
istream& get (streambuf& sb, char delim); |
Get characters
Extracts characters from the stream, as unformatted input:
该方法跟getchar()类似。
http://www.cplusplus.com/reference/istream/istream/get/?kw=cin.get
2.面向对象--构造函数
P297 构造函数的作用,以及缺省构造函数
P300 9.6 错误原因分析
错误实例1:
#include<iostream>
using namespace std;
class TempClass{
public :
int l;
TempClass(){
int l = 5;
}
};
int main(){
TempClass temp(2);
}
错误实例2:
class A{
public :
int s;
A(int newS){
s = newS;
}
void print(){
cout << s;
}
};
int main(){
A a();
a.print();
}
3多维数组
P263 二维数组声明
P267 8.4 二维数组作为参数传递
4,递归
p545 阶乘、斐波那契数列
P556 汉诺塔