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

saving the value from one file to other

100 100+
Hi,
I have a vector in one file which has many items stored and i want to save the value from that file to other.both are using completely different classes, can anyone help?

Do I need to use EXTERN?
Jul 17 '07 #1
1 1316
weaknessforcats
9,208 Expert Mod 8TB
I'm not sure what you mean:

1) access the vector from another file??

2) access a value retreived from the vector??

The ideal answer is:

1) put the vector in a file.
2) put a function in that file that can access the vector.
3) call that function from the other files.

You do not want to extern the vector. If you do, and you later need to chnage the vector to something else, you will have to change all of your code. If you use a function to access the vector, you just need to change that function to implement a new data structure.

Extern implies a global variable and global variables need to be avoided because:

1) local variable hides global variable
2) name conflicts. even within namespaces.
3) exposes implementation. No redesign
4) causes race conditions in multithreaded programs
5) expands ripple when value is screwed up. every function is a suspect
6) no guarantee the user will use global
7) expands program footprint
8) memory for globals may be limited
9) no guarantee for the order of creation. Only the globals in a single file are crerated in the order of declaration. The total order is indeterminate. Hence, your global may no be there when you need it. Especially if a global object needs a global variable in another file in its constructor. aka: the initialization fiasco
10) expands ripple when a recode is needed. All the code using globals has to be changed. Bad if there is a large installed base.

Partial solution:
1) use a namespace or function interface to an anonymous namespace

Best solution:
Use a singleton. destructors can be private to prevent the singleton for being deleted. Read the Singleton article in the C/C++ Articles section.
Jul 17 '07 #2

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

Similar topics

4
by: Jacob H | last post by:
Hello list... I'm developing an adventure game in Python (which of course is lots of fun). One of the features is the ability to save games and restore the saves later. I'm using the pickle...
0
by: mchl gdbt | last post by:
Hi, I have several thousand tiffs generated by application A which are read by application B. I need to remove a few colours from the tiffs and I decided to try with the python imaging library....
7
by: G-Factor | last post by:
Hi all I've just started learning about saving files. I got bit of a problem. The following code gives me an error about incompatible types. (Cannot covert from class character to char *). I...
5
by: ken | last post by:
I have a XML file as below ---------------------------------------------------------------------------------------------------------------------- <?xml version="1.0" standalone="yes"?> ...
2
by: steve | last post by:
Hello, I am trying to import an image file into a form. This would be a persons picture saved in the same directory for every unique record. I don't have any problems making an action button to...
7
by: Kirk | last post by:
Hello, I am trying to find a VB.NET method that will allow me to save and read an application's settings in a separate file located on any drive, any folder. I have found a couple of methods...
1
by: M Keeton | last post by:
I currently have a picture which is stored in a "System.Drawing.Image" variable and I want to save it as a bitmap file. I have tried 2 different approaches and both give me the following error: ...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
6
by: Karl | last post by:
Hi all, It may seem like a rather odd request (or not) but I would like to be able to create a file (doc, jpg, xls or one of many other files that can be automated) on a website and stream it to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.