473,405 Members | 2,154 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,405 software developers and data experts.

DLL Forgetting Values?

1
Sorry if this question has been asked before, but I didn't exactly know how to word my question in the search box to get relevant results.

The app I'm working on determines what DLL to load based on certain criteria. Each DLL implements the same abstract class such as in the example below:

Expand|Select|Wrap|Line Numbers
  1. class MyInterface
  2. {
  3. public:
  4.     void initialize() = 0;
  5.     void doSomething(int i) = 0;
  6.     int getSomeVar() = 0;
  7. }
  8.  
  9. class MyFirstImplementation: public MyInterface
  10. {
  11. public:
  12.     void initialize();
  13.     void doSomething(int i);
  14.     int getSomeVar();
  15. private:
  16.     int _someVar;
  17.     int _anotherVar;
  18. }
By setting a pointer to the base class (in this example, MyInterface), the main app can use the same API across all DLLs. The DLLs each read certain files, store the vital contents in member variables and provide a method to get/set these variables (eg. getSomeVar() returns the contents of _someVar in the example above).

However, I've noticed that the DLLs will "forget" the values in these variables after a while. The first call, immediately after the DLL has loaded the file, everything works. I try and access the variables again at another point in the program (I've made sure that nothing else has accessed the DLL by debugging the program line by line) and the functions begin to return junk values. I've even iterated through every function using for () and found that the second time the functions are called, they begin to return junk (but the first time everything works). No other program is accessing this DLL either.

Has anyone experienced the same or even similar situation? If so, are there any ways to fix it? Any help wold be appreciated. Thanks!
Aug 16 '08 #1
2 1233
JosAH
11,448 Expert 8TB
Possibly your program is suffering from 'slicing'; slicing can happen when you
store an object of a derived class in something that can only hold space for the
base class. The rest or the object will be 'sliced' off.

This behaviour notably happens when you have a vector<BaseClass> and you
want to store DerivedClass objects in it. If this applies to your program better
use a vector<BaseClass*> or vector<BaseClass&> instead.

kind regards,

Jos
Aug 17 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
Where are your base class virtual functions?

Without them you have no polymorphism at all.

Read this: http://bytes.com/forum/thread793836.html.
Aug 17 '08 #3

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

Similar topics

4
by: Steve Hall | last post by:
Folks, My secnario involves two tables - ObservationRegister, and Person. ObservationRegister contains most of the "useful" fields, including the UserID of the person that raised the record, and...
1
by: Siemel Naran | last post by:
Hi. I have a file of test functions. int test1() { return 0; } int test2() return 0; } There is another function that calls all the tests.
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
2
by: Hennie | last post by:
I apologise if this is a stupid question, but I would appreciated any help on this subject. I want to create a view (VIEW_1 in example below) where I take numeric values from a field in one...
8
by: aleksandar.ristovski | last post by:
Hello all, I have been thinking about a possible extension to C/C++ syntax. The current syntax allows declaring a function that returns a value: int foo(); however, if I were to return...
13
by: 010 010 | last post by:
I found this very odd and maybe someone can explain it to me. I was using fread to scan through a binary file and pull bytes out. In the middle of a while loop, for no reason that i could...
13
by: Gregor =?UTF-8?B?S292YcSN?= | last post by:
Hi! With VALUES you can do something like: SELECT * FROM (VALUES ('A', 1), ('B', 2), ('C', 2)) AS TEMP(LETTER, NUMBER) which will give you: LETTER NUMBER ------ ------ A 1 B 2...
2
by: Alexnb | last post by:
Lets say we have this list: funlist = and lets say I do this: if funlist: print funlist I will get the exception "list index out of range"
8
by: gigonomics | last post by:
Hi all, I hope someone can help me out. I need to return the best available seats subject to the constraint that the seats are side by side (or return X consecutive records from a table column...
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: 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
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:
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.