operator overloading? or overriding? What is the right?

I know the difference between overloading and overriding.

overloading is doing add function another version with the same name.
and overriding is to change an original function to custom function with the same header.

Here I have two questions.

1. if I made a copy constructor.

1
2
3
4
5
6
7
8
template <class T>
class MyClass
{
.....
  MyClass(const T& val) {....}
  // is this overriding of copy constructor?
  // or overloading of constructor? 
}


2. If I made a copy operator
1
2
3
4
5
6
template <class T>
class MyClass
{
.....
  T& operator=(const T& val) {....}
}

is this overriding of operator?
or overloading of operator?
I'm not sure it is overriding or overloading.
because I don't know an original operator's header.
but I think it is overriding.
cause It still exist as a default operator, like a default constructor.
even if I do not define an operator or constructor
Last edited on
It's not overriding because you're not overriding a virtual function in the base class.

Normally when you define a member functions it's not considered overloading but I think you could call it that with operators because the syntax is the same whether its a member or not.

1
2
a = b; // The = operator is overloaded for many different types. 
       // Which function is called depends on the type of a and b. 
Thanks for your answer!
Topic archived. No new replies allowed.