Originally Posted by
maven
Great!! I was not aware of it. But people must have to use compiler which supports c++11 to get the advantages.
This was not the point. Ordinarily, POD types aren't constructed at all. But the compiler can generate constructors for them, and you are allowed to use them.
Code:
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
class point
{
private:
float _x;
float _y;
public:
point() : _x(), _y() {}
string toString() const
{
stringstream result;
result << '(' << _x << ',' << _y << ')';
return result.str();
}
};
int main ()
{
point origin;
cout << origin.toString() << endl; // (0,0)
return 0;
}
C++11 support is not necessary.