Could you tell me what's wrong with this program, it doesn't compile:
#include <iostream>
#include <cstdlib>
using namespace std;
class Everything
{
public:
static Everything* Instance()
{
if(instance==0)
instance=new Everything;
return instance;
}
const long double pi;
const long double e;
const long double phi;
private:
Everything():pi (3.14591),e(2.7 1828),phi(1.618 034){}
Everything(cons t Everything&);
Everything& operator=(const Everything&);
private:
static Everything* instance;
};
Everything* Everything::ins tance = 0;// initialize pointer
Everything* var=Instance();
int main()
{
long double* area(const long double& radius, const Everything* var);
long double rad;
cout << "Enter a radius: ";
cin >> rad;
long double* ret=area(rad,va r);
cout << "Area: " << *ret << endl;
delete ret;
system("PAUSE") ;
return EXIT_SUCCESS;
}
long double* area(const long double& radius, const Everything* var)
{
template<class T>T Exp(const T& base,long long exp);
long double* ret=new long double(var->pi*Exp<long double>(radius, 2));
return ret;
}
template<class T>
T Exp(const T& base,long long exp)
{
for(T i=1;exp>0;exp--)
i*=base;
return i;
}
Any suggestions? Thanks!!!