What Is "Operator<<" Called

No matching function for to call operator ++ overloading

The postfix increment is supposed to increment this and return the value before the increment. You get the error because there is no constructor for person taking an int. You can fix that by:

person operator++(int)
{
person temp{name,age};
age++;
return temp;
}

Though better would be to provide a copy constructor and typically postfix increment can be implemented in terms of prefix increment:

// prefix
person& operator++() {
age++;
return *this;
}

// postfix
person operator++(int) {
person temp = *this; // needs copy constructor
++*this;
return temp;
}

For more details on operator overloading I refer you to What are the basic rules and idioms for operator overloading?

Operator on template argument type member causes error only in clang

std::tuple<std::string, std::string>

Let's look at the associated namespaces of this type. [basic.lookup.argdep]/(2.2):

Its associated namespaces are the
innermost enclosing namespaces of its associated classes.

That would be namespace std or auxiliary ones, but certainly not the global namespace.

Furthermore, if T is a class template specialization, its associated
namespaces and classes also include: the namespaces and classes
associated with the types of the template arguments provided for
template type parameters (excluding template template parameters); [… inapplicable rules…]

Recursively applying the above to std::string gives namespace std (and, again, auxiliary ones) for the associated namespaces. Certainly not the global namespace. Clearly, the same argumentation can be repeated for std::cout, giving the same conclusion.

Thus ADL won't look in the global namespace, which is precisely where your overload is declared in.

Finally, as per [temp.dep.candidate]/1, name resolution is unsuccessful:

Sample Image

GCC behaves non-conforming here; see #51577.

What is operator called?

<< left shift

>> right shift

No matching function for call to operator new

To use the standard placement form of new you have to #include <new>.

The form of new that you are using requires a declaration of void* operator new(std::size_t, void*) throw();.

You don't have to #include <new> to use non-placement new.

What is the name of the :: operator?

:: is the scope resolution operator (you may sometimes find references to Paamayim Nekudotayim, hebrew for "double colon"). It is used to call static functions of a class, as in

class MyClass {
public static function hi() {
echo "hello, world";
}
}
MyClass::hi();

For more details on classes and objects, refer to the official documentation.

What is the official name of C++'s arrow (-) operator?

The C++ standard just calls it "arrow" (§5.2.5).



Related Topics



Leave a reply



Submit