CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2007
    Posts
    2

    Exclamation what is the difference between c++ enum and java?

    hi ,


    I'm java developer

    in java it is Objects instead of integer constants .

    I want to ask this question

    What is the fundamental difference between the two ?

  2. #2
    Join Date
    Mar 2007
    Location
    Montreal, Quebec, Canada
    Posts
    185

    Re: what is the difference between c++ enum and java?

    In C/C++, enums are more or less integers (that's the way they are handled under the hood). You can't give your enum methods or anything like that, basically you only capable of making variables of the type and giving them the values you list.

    In Java, your enums can have methods attached, so if you have:
    Code:
    enum bla{
        BLA1, BLA2, BLA3;
    
        public void doStuff(){
            // stuff
        }
    }
    
    BLA1.doStuff();
    It's a bit more complex than this, but that's the jist of it. You can read about it on Sun's site here: http://java.sun.com/j2se/1.5.0/docs/...age/enums.html.

  3. #3
    Join Date
    May 2007
    Posts
    2

    Resolved Re: what is the difference between c++ enum and java?

    thanks, IllegalCharacter

    that's was very helpful.
    Last edited by systematic; May 29th, 2007 at 04:01 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured