473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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???
Dec 20 '07 #1
3 1088
r035198x
13,262 8TB
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.
Dec 20 '07 #2
BigDaddyLH
1,216 Expert 1GB
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.
Dec 20 '07 #3
r035198x
13,262 8TB
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

Expand|Select|Wrap|Line Numbers
  1. public Person() {
  2.    String name = "Silly Me";
  3. }
  4. void someMethod()  {
  5.    name = "Very silly";
  6. }
Dec 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: chris | last post by:
What is a class ?? is it like a function ?? this has allways confused me as i am a newby to programming (since Basic in the 80's) thanks for any insight you can give
3
by: darkstorm | last post by:
I have a doubt regarding inheritance involving templates Consider this: ///////////////////////////////////// template<typename T> class A { private: T m_a;
8
by: gg | last post by:
I am confused regarding what the line in the following function does. It seems to work ok. It seems to be creating a new T object using the pointer to an existing T object. But which function is it...
3
by: Karl M | last post by:
Hi everyone, I just notice some strange behaviors on the MS C++ compiler regarding struct default constructor, see the example bellow: struct MyStruct { int a; }; class MyClass { public:
9
by: kiran.agashe | last post by:
Hi, Please refer program below: #include <string> #include <cstdio> using namespace std; const char* f(); main() {
4
by: ramesh | last post by:
Why do we have a virtual destructor and why cant we have a virtual constructor?
17
by: Ashwin | last post by:
hi guys, i have overloaded the << operator.as shown below. ostream& operator<<(ostream &out, const student &a) { out<<a.idno; out<< " " ; // out<< a.name; out<< " " ; // out<< a.marks...
2
bajajv
by: bajajv | last post by:
Hi, I am confused regarding these concepts. Please clearify. 1. Why is bitwise copying unsafe? 2. Does copy constructor does bitwise copying? 3. Is the main use of explicit copy constructor is...
1
by: msanjayv | last post by:
Hi I have a two doubt's regarding constructor. Consider the following situation. I have two classes A & B. A is the base class and B is a class which inherits class A. I have main...
4
by: Pranav | last post by:
Hello All, I have a simple question regarding the definition of abstract class, IIRC , Abstract class is one which contains virtual function declaration and other variables and no object of this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.