由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++中怎么传递std::hex这样的参数啊
相关主题
子类的assignment operator 怎么访问父类的private memberostream& operator << (ostream& s, int cnt) error
为什么在overloading中,friend <<不能读取private值呢?c++小问题
Why should i include .cpp instead of .hplease help debug this code
请问关于overloading <<能否对某个库进行操作符重载?
C++ problem一个C++的概念问题
overriding operator<<再问两个C++问题
C++重载<<错误?请问这是什么错误呀
问个C++的问题 friend operatorC++ template question with friend ostream
相关话题的讨论汇总
话题: chart话题: ostream话题: traits话题: basic话题: hex
进入Programming版参与讨论
1 (共1页)
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.
1 (共1页)
进入Programming版参与讨论
相关主题
C++ template question with friend ostreamC++ problem
问一个有关iostream的问题overriding operator<<
C++ 请教: about the memory layout of the class inheritanceC++重载<<错误?
C++ template function一个问题问个C++的问题 friend operator
子类的assignment operator 怎么访问父类的private memberostream& operator << (ostream& s, int cnt) error
为什么在overloading中,friend <<不能读取private值呢?c++小问题
Why should i include .cpp instead of .hplease help debug this code
请问关于overloading <<能否对某个库进行操作符重载?
相关话题的讨论汇总
话题: chart话题: ostream话题: traits话题: basic话题: hex