Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

un include

Status
Not open for further replies.

mangocinn

Programmer
Jul 26, 2001
66
US
This may be a strange question...

From a client application, is there a way to uninclude a file that was included in the header file of a class that is being used by the client?
 
I'm not sure I get what you're saying. Are you asking if, once an application has been built, you can remove some of the code used to create it at runtime? Because you definately cannot do that. If you want to like, make a class behave differently or something, you might want to look into using dlls and rename a couple of dlls to use different implementation of the same functions, but you would still need to restart the application. If I understand you correctly, you should post specifically what you are trying to accomplish because there has to be a better way of doing it.
 
Ok...

Let me tell you what I am trying to accomplish so that it is more clear.

I have a test driver that tests the software (a dll with 3 classes) that I had written. In my test driver, I need to simulate the occurence of a null pointer (a private member attribute that gets set when a particular object is created).

I am not sure how to force the pointer to become null through my test driver. Since the #include of the object's header file is what allows the creation of the object, I was trying to figure out how I can "ignore" the #include statement which would result in the object not being able to be created (hence the null member attribute).

Hope that is clear... if not, please let me know.

Any ideas?
 
force the pointer to become null
pointer = NULL;

Excluding class information won't allow you to compile. The only way to force something to be NULL is to assign it NULL, \0 or 0. Since this is a private member your trying to force NULL, the only way to do it is to have a bit of code that looks for a test/debug flag and inside the class assigns it NULL.

Perhaps you are over testing something that isn't very important or is very low risk. If I say:
static const int _BLAH_ = 5; It is probably a waste of testing resorces to try and garuntee that the value hasn't changed and that there really is only one of them.
 
jstreich,

Thank you.

I know, it is kindaa overkill. In the same breath, the creation of this object is important and nothing else will work w/out it so it must be handled appropriately in a error situation.
I have to do it... it is not really my decision.

 
Rather than writing a test harness to test a condition that is almost impossible to test, you might be better off doing a code review of the area that you are concerned with and maybe find places where the developers can add some assert statements or something to handle errors...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top