recompiling..

B

BekTek

I have some qustions about recompiling in c++..

Let me show you my example..
I've got a class which has private member..

class A{
private:
void somefunc();
};

and client using it.. in different file

int main(){
A a;
// use A in whatever ways we want :)
// but except using private function
// Actually that's not legal
}

My question is if I chang the declaration of class A, for example changing
the private function name 'somefunc' to 'anyfunc', will the client code be
recompiled?
 
M

Matthias =?ISO-8859-1?Q?K=E4ppler?=

The pimpl idiom is used for information hiding in the first place. But it
also assures that the client doesn't need to recompile his code unless
there are changes made to the interface, that's correct.
 
R

Rolf Magnus

BekTek said:
I have some qustions about recompiling in c++..

Let me show you my example..
I've got a class which has private member..

class A{
private:
void somefunc();
};

and client using it.. in different file

int main(){
A a;
// use A in whatever ways we want :)
// but except using private function
// Actually that's not legal
}

My question is if I chang the declaration of class A, for example changing
the private function name 'somefunc' to 'anyfunc', will the client code be
recompiled?

What gets recompiled in which situation is not defined in standard C++. It
depends on the toolchain you are using. Usually, some make tool is used. It
has a Makefile, from which it gets dependancy information and rules how to
build what from what. And if some file 'a' depends on a file 'b', and you
change b, a will be recompiled. So in your case, if your class definition
of class A is in a file called a.h and your main() function is in main.cpp,
then main.cpp would be recompiled if a.h was changed, and make doesn't
really care what the change was, just _that_ it changed. But as I said,
this is not a matter of the C++ language, but rather of the toolchain you
use for building your program from the sources.
 

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

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top