I was wanting to implement a simple static class that calculates the pow value of an integer in c++ while practicing. So my codes here:
#pragma once
#ifndef MATH_H
#define MATH_H
static class Math
{
public:
static int pow(int,int);
};
#endif /* MATH_H */
And the implemetation of pow function:
#include "Math.h"
int Math::pow(int base, int exp){
if(exp==1)
return base;
else if(exp%2==0)
return pow(base,exp/2)*pow(base,exp/2);
else
return pow(base,exp/2)*pow(base,exp/2)*base;
}
But the cygwin compiler is throwing compilation error:
In file included from Math.cpp:16:0:
Math.h:16:1: error: a storage class can only be specified for objects and functions
static class Math
^~~~~~

<cmath>already has apowfunction.staticbeforeclass Math.std::powfunction. If you want to use your function, prefix withMath::, e.g.Math::pow.