+ Reply to Thread
Results 1 to 4 of 4

Thread: Get and Set Functions

  1. #1
    Programming Professional Chan is an unknown quantity at this point
    Join Date
    Jun 2006
    Posts
    205

    Get and Set Functions

    I don't really understand the GET and SET functions inside of a function. The functions go like this:

    Code:
    int somefunction() {
    Get {
       return variable;
    }
    
    set {
       variable = this;
    }
    }
    Where do you send the variable for set? When was this added? It seems like a neat way to create functions in classes and not have to create a new get/set function for everything.

  2. #2
    Programmer brackett is on a distinguished road
    Join Date
    May 2006
    Posts
    193
    I think you're describing Properties, but the syntax is a bit off. Instead of function someFunction, it'd be property someProperty.

    The value in the set is implicit - it's what gets passed when you say object.someProperty = x; (x is the passed value).

    It's cleaner than Java's getProperty, setProperty IMHO.

  3. #3
    Kaabi
    Guest
    Yes... Java is cleaner than C++ in some cases. >>... <<...

  4. #4
    Programming God NeedHelp is on a distinguished road
    Join Date
    May 2006
    Posts
    526
    You need these for properties, not functions. You have it wrong.
    I Need Help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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