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

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Tips on how to use IBM iNotes (web client) on emailing or scheduling - Like copy tables from Excel or checking for user id (windows logon id) through email address