473,395 Members | 1,649 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,395 software developers and data experts.

Resetting a class

Lets say I have a class, which creates object and variables. In main how do I reset that class to null, as if it was (the class run for the first time) first run, but without exitting the main?
Mar 6 '08 #1
6 1471
Lets say I have a class, which creates object and variables. In main how do I reset that class to null, as if it was (the class run for the first time) first run, but without exitting the main?
I ve noticed that when I write an if statement, because I only want it it reset "if asked for a reset". It doesn't work. But without the if statement it works. Why is that? How do make it work? I want to make the declaration inside the if block to be global. How do I do that?
Mar 6 '08 #2
JonLT
41
if you declare anything inside an if block the variable will run out of scope i.e end to exist when you are nolonger inside the if block, you need to put the declaration outside the if block
Mar 6 '08 #3
if you declare anything inside an if block the variable will run out of scope i.e end to exist when you are nolonger inside the if block, you need to put the declaration outside the if block
if I put it outside the block, it would reset it even if I don't want it to.
Mar 6 '08 #4
JonLT
41
how about this (I don't know how you code looks)
Expand|Select|Wrap|Line Numbers
  1. SomeClass MyClass;
  2. MyClass.someIntMember = 5;
  3. if(wantToReset)
  4. do the resetting
  5.  
Mar 6 '08 #5
Parul Bagadia
188 100+
You can declare all its objects and variables to null; what about this?
Mar 7 '08 #6
whodgson
542 512MB
If the class has at least a constructor and a destructor there should be no need for resetting - just call the required member function again and it should behave as for the first run.
Mar 7 '08 #7

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

Similar topics

8
by: Nathan Sokalski | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. After the file is successfully submitted, I want the field to be reset so that the user knows the file was...
8
by: Nathan Sokalski | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. After the file is successfully submitted, I want the field to be reset so that the user knows the file was...
4
by: Ian Davies | last post by:
Hello I am struggling for a solution to clear some fields on my webpage that takes their values from some sessions My solution below works when the button is clicked twice. I sort of know why I...
3
by: geraldjr30 | last post by:
hi, i managed to reset the $_GET to $_POST passed from previous page, but for some reason when i type in a in the form it resets back to all. i do not want this to happen... can someone look...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.