Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. what ALL gets created by an empty class? (c++)

what ALL gets created by an empty class? (c++)

Scheduled Pinned Locked Moved C / C++ / MFC
c++questioncareer
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dd314159
    wrote on last edited by
    #1

    Hey there - what happens when someone creates a class: class empty{ }; I know there are the four member functions that would be created - constructor, destructor, assignment and copy. but what else? I was asked this in an interview and confidently replied with the four functions above - only to be told that really knowledgable C++ folks would be able to name anywhere between 6 - 9 things. Any other answers out there? I've looked online and in all my c++ books. Thanks!

    D J 2 Replies Last reply
    0
    • D dd314159

      Hey there - what happens when someone creates a class: class empty{ }; I know there are the four member functions that would be created - constructor, destructor, assignment and copy. but what else? I was asked this in an interview and confidently replied with the four functions above - only to be told that really knowledgable C++ folks would be able to name anywhere between 6 - 9 things. Any other answers out there? I've looked online and in all my c++ books. Thanks!

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      dd314159 wrote:

      Any other answers out there?

      The compiler might also create address-of operators. That said, these (five) items don't always get created, only when they are needed.

      "Love people and use things, not love things and use people." - Unknown

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      D 1 Reply Last reply
      0
      • D dd314159

        Hey there - what happens when someone creates a class: class empty{ }; I know there are the four member functions that would be created - constructor, destructor, assignment and copy. but what else? I was asked this in an interview and confidently replied with the four functions above - only to be told that really knowledgable C++ folks would be able to name anywhere between 6 - 9 things. Any other answers out there? I've looked online and in all my c++ books. Thanks!

        J Offline
        J Offline
        Jijo Raj
        wrote on last edited by
        #3

        dd314159 wrote:

        I know there are the four member functions that would be created - constructor, destructor, assignment and copy. but what else?

        Not always. For instance, the compiler will provide constructor only if there are some virtual functions(to prepare vtable), or if any of the member variables have constructors. I strongly recommend you to read the book "Inside C++ Object Model". http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545[^] Regards, Jijo.

        _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

        D 1 Reply Last reply
        0
        • J Jijo Raj

          dd314159 wrote:

          I know there are the four member functions that would be created - constructor, destructor, assignment and copy. but what else?

          Not always. For instance, the compiler will provide constructor only if there are some virtual functions(to prepare vtable), or if any of the member variables have constructors. I strongly recommend you to read the book "Inside C++ Object Model". http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545[^] Regards, Jijo.

          _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

          D Offline
          D Offline
          dd314159
          wrote on last edited by
          #4

          Thanks - this is just the type of book I've been looking for to know what's really going on.

          1 Reply Last reply
          0
          • D David Crow

            dd314159 wrote:

            Any other answers out there?

            The compiler might also create address-of operators. That said, these (five) items don't always get created, only when they are needed.

            "Love people and use things, not love things and use people." - Unknown

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            D Offline
            D Offline
            dd314159
            wrote on last edited by
            #5

            Thanks!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups