作者ric2k1 (Ric)
看板EE_DSnP
标题Re: [问题] 问几个问题
时间Thu Oct 18 09:29:32 2007
※ 引述《popo4231 (小泰)》之铭言:
: 关於#homework3的几个问题
: 1:请问string可以用什麽方法转换成int吗
: static_cast<int>(string物件)的方法compile不给过
For "static_cast", FYI:
http://msdn2.microsoft.com/en-us/library/ms861534.aspx
In short, it can convert integral type to integral type, floating to floating,
pointer to pointer, but not mixed.
You can try---
string str = ......;
char* strChar = str.c_str();
int i = atoi(strChar); // but only good for 32-bit integer
: 2:可以宣告member function中区域变数为long lnog
: 但是data member中只有unsigned int吗
不行... 这样子就没有意义了.
: 3:可以用字元阵列吗
可以, 但请考虑 memory 与 runtime efficiency.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.21.241
1F:推 flarehunter:老师说的考虑memory 是所有的memory不能超过64bit吗?! 10/19 07:59