// ReloadOper.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<stdio.h>
#include<math.h>
class CFloat
{
private:
float m_a;
public:
CFloat(float a)
{
m_a=a;
}
friend double operator^(CFloat &a,int &b)//;//要加声明
{
return pow(a.m_a,b);
}
};
int main(int argc, char* argv[])
{
float b=2.5;
int c=2;
double a=CFloat(b)^c;
printf("%f\n",a);
return 0;
}
/*
6.250000
Press any key to continue
*/
重载乘方运算
最新推荐文章于 2022-10-24 09:08:15 发布