很簡單的一斷代碼,但是被迷惑了。
int main()
{
char cval;
cval = 'a' + 3;
cout << cval << endl;
system("pause");
return 0;
}
你若不生死相依,我必離你而去。
#include <iostream>
using namespace std;
int main()
{
char cval;
cval = 'a' + 3;
cout << cval << endl;
int i ;
double d;
const string *ps;
char *pc;
void *pv;
pv = const_cast<string*>(ps);
cout<<"const_cast<string*>(ps)"<<pv<<endl;
pv = (void*)ps;
cout<<"pv=(void*)ps"<<pv<<endl;
i = static_cast<int>(*pc);
cout<<"static_cast<int>(*pc)"<<i<<endl;
i = int(*pc);
cout<<"int(*pc)"<<i<<endl;
pv = reinterpret_cast<double*>(&d);
cout<<"reinterpret_cast<double*>(&d)"<<pv<<endl;
pv=&d;
cout<<"pv=&d"<<pv<<endl;
pc = static_cast<char*>(pv);
cout<<"static_cast<char*>(pv)"<<pc<<endl;
pc = (char*)pv;
cout<<"pc=(char*)pv"<<pc<<endl;
return 0;
}
至今未看懂,至今沒看會,我脖子疼,睡覺~~~