社区
C语言
帖子详情
operator short () const;
pan2008
2003-08-22 09:15:43
这个怎么理解
operator short () const;
...全文
45
2
打赏
收藏
operator short () const;
这个怎么理解 operator short () const;
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用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++ 读取bmp图片示例程序
功能: 读取bmp 代码示例: typedef struct _bmpsize { long bmpWidth;//位图宽,单位为象素LONG=long(有符号) long bmpHeight;//位图高,单位为象素LONG=long(有符号) unsigned
short
BitCount;//每个象素所占用的比特位WORD=unsigned
short
long BytesPerLine;//位图每行数据所占的字节数LONG=long(有符号) bool
operator
==(_bmpsize bs) { if(bmpWidth==bs.bmpWidth && bmpHeight==bs.bmpHeight && BitCount==bs.BitCount /*&&BytesPerLine==bs.BytesPerLine*/) return true; else return false; } bool
operator
!=(_bmpsize bs) { return !(*this==bs); } }BMPSIZE, *LPBMPSIZE;//位图大小信息 class scBmp { public: scBmp(); virtual ~scBmp(); BITMAPFILEHEADER GetBmpFileHeader()
const
{return m_bmfHeader;};
const
char * GetFileName()
const
{return m_pFileName.GetDataPointer();} BITMAPINFO * GetBmpInfo()
const
{return (BITMAPINFO *)m_pbi.GetDataPointer();} BMPSIZE GetBmpSize()
const
{return m_bmpSize;} // scFdmtlType * GetPixels() {return &m_pixels;} scBYTE * GetPixels() {return &m_pixels;}
C++关键字详细使用
asm auto bad_cast bad_typeid bool break case catch 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
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 using virtual void volatile while
C++关键字大全(67个).txt
C++关键字大全(67个) asm auto bad_cast bad_typeid bool break case catch 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
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 using virtual void volatile wchar_t while
C/C++对bool
operator
< (
const
p &a)
const
的认识,运算符重载详解(杂谈)
下面来进行这段代码的分析: structnode{//定义一个结构体node(节点) intx; inty; intlen;//node中有3个成员变量x,y,len bool
operator
<(
const
node&a)
const
{//重载<操作符。可以对两个node使用<操作符进行比较 ...
c++ |
const
(成员函数) | 「尽可能多用
const
,如成员函数」
class TextBlock{ public: ...
const
char&
operator
[] (std::size_t pos)
const
{ return text[pos]; //
const
成员函数 } char&
operator
[] (std::size_t pos) { return text[pos]; //.
C语言
69,382
社区成员
243,073
社区内容
发帖
与我相关
我的任务
C语言
C语言相关问题讨论
复制链接
扫一扫
分享
社区描述
C语言相关问题讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章