regarding constructor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gopalmys
    New Member
    • Dec 2007
    • 1

    regarding constructor

    hi,
    i have a constructor i assigned some value to its data memeber whenever the programme ends my object goes out of scope obviously i loose the data i want to save that data what i have to do???
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by gopalmys
    hi,
    i have a constructor i assigned some value to its data memeber whenever the programme ends my object goes out of scope obviously i loose the data i want to save that data what i have to do???
    Declare the members outside the constructor.

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      Originally posted by gopalmys
      hi,
      i have a constructor i assigned some value to its data memeber whenever the programme ends my object goes out of scope obviously i loose the data i want to save that data what i have to do???
      You want your data to be saved when the program ends? You will either have to save it to a file or use a database.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by BigDaddyLH
        You want your data to be saved when the program ends? You will either have to save it to a file or use a database.
        Oh, I didn't notice they'd said when the programme ends. I assumed it's the typical

        [CODE=java]public Person() {
        String name = "Silly Me";
        }
        void someMethod() {
        name = "Very silly";
        }[/CODE]

        Comment

        Working...