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. constant member function in Managed C++

constant member function in Managed C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
6 Posts 6 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.
  • A Offline
    A Offline
    Andy Rama
    wrote on last edited by
    #1

    Hi to all, How to write a constant member function in Managed C++ class.

    public ref class CMyClass
    {
     public :
       void Function(void) const
       {
       }
    }
    

    Here I got error as, error C3842: 'Function': 'const' and 'volatile' qualifiers on member functions of managed types are not supported - Aniket A. Salunkhe

    CPalliniC J D S 4 Replies Last reply
    0
    • A Andy Rama

      Hi to all, How to write a constant member function in Managed C++ class.

      public ref class CMyClass
      {
       public :
         void Function(void) const
         {
         }
      }
      

      Here I got error as, error C3842: 'Function': 'const' and 'volatile' qualifiers on member functions of managed types are not supported - Aniket A. Salunkhe

      CPalliniC Online
      CPalliniC Online
      CPallini
      wrote on last edited by
      #2

      [^]. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • A Andy Rama

        Hi to all, How to write a constant member function in Managed C++ class.

        public ref class CMyClass
        {
         public :
           void Function(void) const
           {
           }
        }
        

        Here I got error as, error C3842: 'Function': 'const' and 'volatile' qualifiers on member functions of managed types are not supported - Aniket A. Salunkhe

        J Offline
        J Offline
        Jagdish V Bhimbha
        wrote on last edited by
        #3

        Hi, Please try this technique,

        public ref class CMyClass
        {
        public:
        void Function(void) const;
        };

        void CMyCLass::Function() const
        {
        .
        . // Code definition
        .
        }

        Wish you Good Luck...:rose:

        Jagdish Bhimbha S/W Developer

        1 Reply Last reply
        0
        • A Andy Rama

          Hi to all, How to write a constant member function in Managed C++ class.

          public ref class CMyClass
          {
           public :
             void Function(void) const
             {
             }
          }
          

          Here I got error as, error C3842: 'Function': 'const' and 'volatile' qualifiers on member functions of managed types are not supported - Aniket A. Salunkhe

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

          Aniket Salunkhe wrote:

          error C3842: 'Function': 'const' and 'volatile' qualifiers on member functions of managed types are not supported

          See here.

          "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

          1 Reply Last reply
          0
          • A Andy Rama

            Hi to all, How to write a constant member function in Managed C++ class.

            public ref class CMyClass
            {
             public :
               void Function(void) const
               {
               }
            }
            

            Here I got error as, error C3842: 'Function': 'const' and 'volatile' qualifiers on member functions of managed types are not supported - Aniket A. Salunkhe

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #5

            The error message pretty much says it all. I can't understand why you felt the need to post the question.

            Steve

            I 1 Reply Last reply
            0
            • S Stephen Hewitt

              The error message pretty much says it all. I can't understand why you felt the need to post the question.

              Steve

              I Offline
              I Offline
              ian__lindsay
              wrote on last edited by
              #6

              I think there is a wider question here - are we saying that the .net languages do not support const correctness at all, or is the syntax just different? Unless you didn't guess I am from a C++ background! For instance if I have a const handle to an object, how do I restrict the caller to only calling certain functions - for instance getters which do not modify the object and not setters which would cause the object to be modified?

              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