社区
C语言
帖子详情
operator short () const;
pan2008
2003-08-22 09:15:43
这个怎么理解
operator short () const;
...全文
67
2
打赏
收藏
operator short () const;
这个怎么理解 operator short () const;
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
feixue3000
2003-08-22
打赏
举报
回复
here is a test:
class A
{
public:
char c;
operator short ()const{return c;}
};
int main(int argc, char *argv[])
{
A a1,a2;
a1.c = 'd';
a2.c = 'G';
cout << a1.c << a2.c << endl;;
short s1 = a1;
cout << s1 << endl;;
s1 += a2;
cout << s1 << endl;;
system("PAUSE");
return 0;
}
feixue3000
2003-08-22
打赏
举报
回复
重载short关键字,const代表本函数不会修改任何数值。
C++程序设计 运算符重载实验(一)
Complex
operator
+(
const
Complex &c2)
const
{ return Complex(real + c2.real, imag + c2.imag); } // 重载运算符- Complex
operator
-(
const
Complex &c2)
const
{ return Complex(real - c2.real, imag - ...
C++ 读取bmp图片示例程序
const
char * GetFileName()
const
{return m_pFileName.GetDataPointer();} BITMAPINFO * GetBmpInfo()
const
{return (BITMAPINFO *)m_pbi.GetDataPointer();} BMPSIZE GetBmpSize()
const
{return m_bmpSize;}...
C++关键字详细使用
char class
const
const
_cast continue default delete do double dynamic_cast else enum except explicit extern false finally float for friend goto if inline int long mutable namespace new
operator
...
C++关键字大全(67个).txt
operator
private protected public register reinterpret_cast return
short
signed sizeof static static_cast struct switch template this throw true try type_info typedef typeid typename union unsigned ...
C/C++对bool
operator
< (
const
p &a)
const
的认识,运算符重载详解(杂谈)
下面来进行这段代码的分析: struct node { //定义一个结构体node(节点... bool
operator
<(
const
node &a)
const
{//重载<操作符。可以对两个node使用<操作符进行比较 ...
C语言
70,023
社区成员
243,263
社区内容
发帖
与我相关
我的任务
C语言
C语言相关问题讨论
复制链接
扫一扫
分享
社区描述
C语言相关问题讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章