65,211
社区成员
发帖
与我相关
我的任务
分享
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
int n;
char *str = "12345.67";
n = atoi(str);
printf("string = %s integer = %d\n", str, n);
return 0;
}
template<typename T> class A
{
public:
const T operator + (const T& rhs)//重载+号
{
return this->m_ + rhs;
}
private:
T m_;
};
class A
{
public:
operator B* () { return this->b_;}
operator const B* () {return this->b_;}
operator B& () {return *this->b_;}
private:
B* b_;
};
A a;
//当if(a),编译时,其中它转换成if(a.operator B*()),其实也就是判断 if(a.b_)