您的位置:首页 > 编程语言 > C语言/C++

c++ note some detail

2014-01-29 15:11 197 查看
cin>> will check digit or other string automatically but cin.get don't check it

#include<iostream>

using namespace std;

int main()

{

char one_char,decimal_point,digit1,digit2;

long dollars;

bool negative;

cin>>one_char;

if(one_char == '-')

{

negative = true;

cin >> one_char;

}

else

{

negative=false;

}

cin>>dollars>>decimal_point>>digit1>>digit2;

cout<< dollars <<" "<<decimal_point <<" "<<digit1<< " " <<digit2<<endl;

}

static_cast<int>(v_char)-static_cast<int>('0'); --return cast char to int

operator + or - or other applay a class instance+20 must be let os known how the 20 add the instance

first check operator fail then call instructor implicitly

ostream & operator<<(ostream & outs ,const class& cs)

big three copy constructor 、operator equal and destructor

unnamed namespace {} is local to compilation unit. global namespace
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: