473,513 Members | 6,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recompilation problem

Hi all,

I have a situation something like this

Class A
{
private data
......
public functions
f1();
f2();
f3();
}

There is another application which uses this class

Class B
{
#include a.h
A objofA;
........
........
}

If I make any changes to the implementation of class A, I need to
recompile the class B. How do I ensure that even if I do any changes to
class A, I don't need to recompile class B. If there any facility
provided by C++ for that?

Sep 18 '05 #1
3 1262
ar********@yahoo.co.in wrote:
Hi all,

I have a situation something like this

Class A
{
private data
......
public functions
f1();
f2();
f3();
}

There is another application which uses this class

Class B
{
#include a.h
A objofA;
........
........
}

If I make any changes to the implementation of class A, I need to
recompile the class B. How do I ensure that even if I do any changes to
class A, I don't need to recompile class B. If there any facility
provided by C++ for that?


Yes, it has a strange name. It's called the pimpl idiom (pimpl strands
for pointer to implementation, who makes this up?).

The idea is to use a pointer to the A object in your B class. Now there
are lots of reasons not to do this, it's less efficient and it makes
coding the B class more complex, but if your overriding concern is to
avoid recompilation then it works.

Like this

class A; // forward declaration

class B
{
A* ptrofA;
};

By using a forward declaration of class A you avoid having to #include
"a.h" in b.h, so there is no recompilation when a.h changes.

john
Sep 18 '05 #2
Hi John,

Thanx a lot for the reply.

I am curious to understand how the compiler takes care of this
situation.
Any idea how it is internally taken care of/implemented. Any pointers
in this regard are highly appreciated.

Thanx in Advance,

Regards,
Aruna

John Harrison wrote:
ar********@yahoo.co.in wrote:
Hi all,

I have a situation something like this

Class A
{
private data
......
public functions
f1();
f2();
f3();
}

There is another application which uses this class

Class B
{
#include a.h
A objofA;
........
........
}

If I make any changes to the implementation of class A, I need to
recompile the class B. How do I ensure that even if I do any changes to
class A, I don't need to recompile class B. If there any facility
provided by C++ for that?


Yes, it has a strange name. It's called the pimpl idiom (pimpl strands
for pointer to implementation, who makes this up?).

The idea is to use a pointer to the A object in your B class. Now there
are lots of reasons not to do this, it's less efficient and it makes
coding the B class more complex, but if your overriding concern is to
avoid recompilation then it works.

Like this

class A; // forward declaration

class B
{
A* ptrofA;
};

By using a forward declaration of class A you avoid having to #include
"a.h" in b.h, so there is no recompilation when a.h changes.

john


Sep 19 '05 #3
ar********@yahoo.co.in wrote:

Hi John,

Thanx a lot for the reply.

I am curious to understand how the compiler takes care of this
situation.
Any idea how it is internally taken care of/implemented. Any pointers
in this regard are highly appreciated.


The key point is, that class B contains only a pointer
to another object. The compiler knows how big such a pointer
is going to be. It doesn't need to know the internals of class A
to determine this size information. Pointers to objects have always the
same size.

--
Karl Heinz Buchegger
kb******@gascad.at
Sep 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5946
by: FuzzyBear | last post by:
Hi, How do dependencies work with Oracle reports? I have a set of developers creating reports in Report Builder 6 w/ Oracle 8i and every time the stored packages change that the report uses,...
117
7102
by: Peter Olcott | last post by:
www.halting-problem.com
1
3650
by: levtoma | last post by:
Hello, We have an ADO.NET application using .NET version 1.1.4322 SP1. It is calling stored procedures in a database that it never written to. The only thing the stored procedures do is a...
1
8492
by: nate.hughes | last post by:
Ok, here's my dilemma. We're running SQL Server 2000 with the default db setting for the ANSI_WARNINGS option set to off. However, we still get "Warning: Null value is eliminated by an aggregate...
0
1529
by: nate.hughes | last post by:
Ok, here's my dilemma. We're running SQL Server 2000 with the default db setting for the ANSI_WARNINGS option set to off. However, we still get "Warning: Null value is eliminated by an aggregate...
1
1779
by: NonDeterministic | last post by:
Hello! Everytime I recompile a program with csc, I have to go to ".NET Framework 2.0 Configuration" / Runtime Security Policy and increase the assembly trust to make it run properly. How can I...
5
2811
by: Jason Collins | last post by:
There are a number of stored procedures involved in sql server based session maintenance: - TempUpdateStateItemShort - TempResetTimeout - TempUpdateStateItemLong etc. These stored procs are...
1
1170
by: NIan | last post by:
Hi, I have a question about having runtime recompilation of the asp.net web application dll file. so my scenario is having existing method dynamiclly . I know easier way is to I/O out those...
4
1384
by: VB Programmer | last post by:
For a 2003 ASP.NET site, when is recompilation of the site on the server done? Only after the site is updated, or every time there has been a lull in visits and someone visits it for the first...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7373
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,...
1
7094
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...
1
5079
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...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.