compilation dependencies ..

A

Anand

I've a singleton object declaration in C++ in which there are other
classes' POINTERS declared as private members as shown below.

// CSingleton.h

Class Singleton
{

private:
CObject1 *obj1; // defined inCObject1.h
CObject2 *obj2; // defined in CObject2.h
Cobject3 *obj3; // defined in CObject3.h
}
I'm on a HP-UX, and in one of the cpp files the Singleton object is
created(CSingleton.h). If one of the objects viz., CObject ; CObject2
;
CObject3 changes (ie., a change in the header)will i have to recompile
the cpp file.?? As of now, I recompile the cpp before execution.
Incase if I choose not to recompile the cpp file, will it cause any
future errors which might go undetected during compilation??

Regards
Anand
 
V

Victor Bazarov

Anand said:
I've a singleton object declaration

....you mean "definition"...
in C++ in which there are other
classes' POINTERS declared as private members as shown below.

// CSingleton.h

Class Singleton
{

private:
CObject1 *obj1; // defined inCObject1.h
CObject2 *obj2; // defined in CObject2.h
Cobject3 *obj3; // defined in CObject3.h
} ;

I'm on a HP-UX, and in one of the cpp files the Singleton object is
created(CSingleton.h).

One of the cpp files is an .h file? I am not sure I understand.
If one of the objects viz., CObject ; CObject2
;
CObject3 changes (ie., a change in the header)will i have to recompile
the cpp file.??

It depends on whether you use the CObject3 class in it or not.
Usually, if 'obj3' is obtained from 'new' (that is, CObject3
is instantiated), you will need to recompile. If you obtain
your 'obj3' pointer from other function, there may not be a need
to recompile.
As of now, I recompile the cpp before execution.

That's a safe approach.
Incase if I choose not to recompile the cpp file, will it cause any
future errors which might go undetected during compilation??

It is impossible to tell. My crystal ball is not working today.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top