百分请教,类型转换问题
C++的这种风格的代码是什么意思?是指针的强制类型转换吗?
有什么好处?会不会有什么风险?
Subscription *subscription = (Subscription *) event->data_;
其中
event的data_成员是一个char data_[MAX_PAYLOAD_SIZE];
Subscription 是一个类,定义如下:(也没见到用户定义的类型转换)
class Subscription
{
// = TITLE
// Allows Consumers to subscribe to be routed information
// arriving from a particular Supplier connection id.
public:
void decode (void)
{
this->connection_id_ = ntohl (this->connection_id_);
for (ACE_INT32 i = 0; i < this->total_consumers_; i++)
this->consumers_[i] = ntohl (this->consumers_[i]);
this->total_consumers_ = ntohl (this->total_consumers_);
}
// Decode from network byte order to host byte order.
void encode (void)
{
this->connection_id_ = htonl (this->connection_id_);
for (ACE_INT32 i = 0; i < this->total_consumers_; i++)
this->consumers_[i] = htonl (this->consumers_[i]);
this->total_consumers_ = htonl (this->total_consumers_);
}
// Encode from host byte order to network byte order.
ACE_INT32 connection_id_;
// Connection id.
ACE_INT32 consumers_[MAX_CONSUMERS];
// Connection ids for consumers that will be routed information
// containing this <connection_id_>
ACE_INT32 total_consumers_;
// Total number of these consumers.
};
有什么好处?会不会有什么风险?
Subscription *subscription = (Subscription *) event->data_;
其中
event的data_成员是一个char data_[MAX_PAYLOAD_SIZE];
Subscription 是一个类,定义如下:(也没见到用户定义的类型转换)
class Subscription
{
// = TITLE
// Allows Consumers to subscribe to be routed information
// arriving from a particular Supplier connection id.
public:
void decode (void)
{
this->connection_id_ = ntohl (this->connection_id_);
for (ACE_INT32 i = 0; i < this->total_consumers_; i++)
this->consumers_[i] = ntohl (this->consumers_[i]);
this->total_consumers_ = ntohl (this->total_consumers_);
}
// Decode from network byte order to host byte order.
void encode (void)
{
this->connection_id_ = htonl (this->connection_id_);
for (ACE_INT32 i = 0; i < this->total_consumers_; i++)
this->consumers_[i] = htonl (this->consumers_[i]);
this->total_consumers_ = htonl (this->total_consumers_);
}
// Encode from host byte order to network byte order.
ACE_INT32 connection_id_;
// Connection id.
ACE_INT32 consumers_[MAX_CONSUMERS];
// Connection ids for consumers that will be routed information
// containing this <connection_id_>
ACE_INT32 total_consumers_;
// Total number of these consumers.
};
...全文
相关推荐
Java实现百分比
NULL 博文链接:https://zhaoshijie.iteye.com/blog/798719
JS求百分比保留两位[可运行源码]
本文介绍了在JavaScript中计算两个数的百分比并保留小数点后两位的方法。通过定义一个名为toPercent的函数,接收两个参数num和total,函数内部使用Math.round方法对计算结果进行四舍五入,确保百分比精确到小数点后两位。调用时需注意参数的强类型转换,以避免潜在的计算错误。示例代码展示了如何调用该函数,适用于需要精确百分比计算的场景。
C#实现百分比转小数的方法
主要介绍了C#实现百分比转小数的方法,涉及C#进行数值计算的相关技巧,需要的朋友可以参考下
MySQL常用类型转换函数总结(推荐)
主要介绍了MySQL常用类型转换函数总结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
用百分数解决问题3练习题及答案精选.doc
用百分数解决问题3练习题及答案精选.doc


