Is it possible to return an object from a static method in C++ like there is in Java? I am doing this:
class MyMath {
public:
static MyObject calc
Try this way
#include
using namespace std;
class MyMath {
public:
static MyMath* calcSomething(void);
private:
};
MyMath* MyMath::calcSomething()
{
MyMath *myMathObject=new MyMath;
return myMathObject;
}
int main()
{
MyMath *myMathObject=MyMath::calcSomething();
/////Object created and returned from static function calcSomeThing
}
Thanks