g*****u 发帖数: 298 | 1 我想写个函数,可以传递进去 hex, dec等等,函数声明应该怎么写? |
t****t 发帖数: 6806 | 2 these are io manipulators. they are actually function pointers. for example,
ostream::operator<< actually has following overloads:
/* template <...> class basic_ostream { */
basic_ostream& operator<<
(basic_ostream& (*pf)(basic_ostream&));
basic_ostream& operator<<
(basic_ios& (*pf)(basic_ios&));
basic_ostream& operator<<
(ios_base& (*pf)(ios_base&));
【在 g*****u 的大作中提到】 : 我想写个函数,可以传递进去 hex, dec等等,函数声明应该怎么写?
|
l****n 发帖数: 727 | 3 看不懂 这怎么用来解决传递hex的问题。
通过io把数变成hex?
example,
));
【在 t****t 的大作中提到】 : these are io manipulators. they are actually function pointers. for example, : ostream::operator<< actually has following overloads: : /* template <...> class basic_ostream { */ : basic_ostream& operator<< : (basic_ostream& (*pf)(basic_ostream&)); : basic_ostream& operator<< : (basic_ios& (*pf)(basic_ios&)); : basic_ostream& operator<< : (ios_base& (*pf)(ios_base&));
|
t****t 发帖数: 6806 | 4 你自己的function也定义成这样的protocol就行了
【在 l****n 的大作中提到】 : 看不懂 这怎么用来解决传递hex的问题。 : 通过io把数变成hex? : : example, : ));
|
a**u 发帖数: 5 | 5 look for the definition of hex, oct, etc. in header file
and that's the type you need. |