Author Topic: Object's function = default  (Read 2098 times)

Offline perezprograms

  • Single posting newcomer
  • *
  • Posts: 4
Object's function = default
« on: August 30, 2021, 04:14:58 am »
Hello everyone,

I am quite new to the forums and I am not sure how to perform the search for the subject. Hopefully, someone may edify me on this process. Please note, I am working with olcNes's header file. In it, there is a pixel class. For some reason, the pixel has an operator equal function. I understand why it would. The confusing part is this function looks like:

Pixel& operator(. . . ) = default;

What does the "= default" do? Does this tell the compiler to replace it with
Pixel& Pixel::operator=( . . . )
{
      if( this != . . . )
      {
          this = & . . . ;
       }
       return *this;
}

Or something else entirely?

Thank you for looking at this post and showing me both what = default means as well as how to search on these forums.

Online stahta01

  • Lives here!
  • ****
  • Posts: 7191
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2317
Re: Object's function = default
« Reply #2 on: August 30, 2021, 06:46:26 am »
Google "c++ operator = default" (without the quotes)

Look at second result.

Offline perezprograms

  • Single posting newcomer
  • *
  • Posts: 4
Re: Object's function = default
« Reply #3 on: September 11, 2021, 01:46:40 am »
Thank you Pecan. That second link is quite useful. Now, I know what "= default means".