C++ 0x – Implicit Callable Functions(ICF)

 

In the new proposed standard for C++, for the functions, which are taking empty number of arguments, now it can be called without paranthesis . It gives a look of property of classes, offer by languages like C#. See the example below

int GetBkColor () implicit { return 0; }Â
// The above function can be called asÂ
int nDrawColor = GetBkColor;
// No paranthesis required
Â
Implicit function calls can be used with classes for getting and setting properties.
Â
class Square {
public:

double & side() implicit { return side_; }
// …
private:
double side_; // length in cm
};
Â
Square s;
s.side = 5.0; // set value
cin >> s.side; // set value
cout<< s.side; // get value
Â

In the above example making the function non-const will enable itself to get and set the values. 

Checkout the ICF Proposal