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. Another academic inquiry - what is the protected / private code purpose / function in this class generated by ATmel STudio

Another academic inquiry - what is the protected / private code purpose / function in this class generated by ATmel STudio

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 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.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    class M { //variables public: protected: private: //functions public: M(); ~M(); virtual int foo(int); protected: private: M( const M &c ); M& operator=( const M &c ); int i, j; }; //M Thanks, any help as always is appreciated. Cheers Vaclav

    L F 2 Replies Last reply
    0
    • V Vaclav_

      class M { //variables public: protected: private: //functions public: M(); ~M(); virtual int foo(int); protected: private: M( const M &c ); M& operator=( const M &c ); int i, j; }; //M Thanks, any help as always is appreciated. Cheers Vaclav

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      They are merely section markers, probably put in by some automatic code generator. They allow the developer to easily add properties and functions in the correct places.

      1 Reply Last reply
      0
      • V Vaclav_

        class M { //variables public: protected: private: //functions public: M(); ~M(); virtual int foo(int); protected: private: M( const M &c ); M& operator=( const M &c ); int i, j; }; //M Thanks, any help as always is appreciated. Cheers Vaclav

        F Offline
        F Offline
        Freak30
        wrote on last edited by
        #3

        If your question is, why the copy constructor and assignment operator are declared private: This is to prevent the users of the class from copying objects of that type. At least the assignment operator is created atomatically by the compiler, if the designer of the class doesn't explicitely specify one. This default assignment operator simply copies all members. So without the operator you could write

        M m1, m2;
        m2 = m1;

        and it would compile. With this class definition as it is, you will get a compile time error that the operator is not accessible.

        The good thing about pessimism is, that you are always either right or pleasently surprised.

        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