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
#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
相关文章推荐
- Some interesting facts about static member functions in C++
- C++ note
- Some Notes of Protocol Buffer C++
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- Some experienced note of bugs
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .
- C++ Note
- Note C/C++
- Come up and C++ me some time ~ (chapter 7~11)
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- study note -(some good sentence)
- some note
- some note about js
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 解决方法
- 【C++】C++0x :: Introduction to some amazing features
- 重学C++(2)——指向类成员的指针(转自:http://www.wangchao.net.cn/bbsdetail_73812.html)
- Inside The C++ Object Model(Note):sizeof in an object
- Eclipse 出现Some sites could not be found. See the error log for more detail.错误 解决方法
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- Some note when comminucate with people