Operator overload

A a;

if(a) <--- this will trigger operator bool() and also operator void const*() const{
{
}


}

boost style
(typedef T * (this_type::*unspecified_bool_type)() const;operator unspecified_bool_type() const // never throws{return px == 0? 0: &this_type::get;})

if (a == "ss") <-- a combinations of few operator overload.

Foo(std::string const& s);
Foo(std::string s);

bool operator==(Foo const& lhs, Foo const& rhs);

For []

int& operator[] (unsigned i) { return data[i]; }


class A
{
public:
enum enA { A1, A2, A3 };
A() { }
~A() { }

operator A::enA() { return A2; }

};

void Fn(A::enA e)
{
std::cout << "Fn(A::enA)\n";

}

when
A a;
Fn(a); // Will call Fn(A::enA) due to overload of operator A::enA()

Comments

Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script

MSSQL GROUP_CONCAT

Duplicating a local copy of project from TFS and making web software client factory to work