Hi Greg,
Thanks for the reply. Actully I am maintaining a project that was
written way back in 1998! Well talking about the main classes, it has
two of them,
DBMgr and DBOps
DBMgr is responsible for opening a connection to the SQL Database and
the DBOps manages the SQL Statements like Insert, Update / Delete etc.
The DBOps is a member class of DBMgr and in the Connection handle is
assigned to the DBOps object through its constructor.
Now the problem is that other classes uses a ref object of the DBOps to
perform DB Operations directly. There are times when the DB Connection
gets broken and DBOps dont know how to connect / reconnect back. Since
only DBMgr knows how to do it.
So I thought if I can get a ref of DBMgr inside DBOps class, I can just
call the connect method which will automatically assign the connection
handle to the required classes.
I hope I was able to explain clearly... I dont see if there is any
other way.
Oh yes I thought of defining the Connect / Disconnect method as static
but then I will have to change all the member variables used inside
them as static too... THIS I dont want to do :-)
Is there any other way to do this? Or usin this cyclic relation is the
only way?
Best Regards,
Faisal.
Greg Comeau wrote:
In article <11************ *********@p79g2 000cwp.googlegr oups.com>,
faisalee <fa******@gmail .comwrote:
I have a question. Here goes:
class clsManager {
public:
int x;
int y;
}
class clsContainer {
public:
int a;
int b;
clsManager oManager;
}
So I have these two classes, first class is a member of second class.
Is it possible to to access members of class clsContainer from the
object oManager ? How can it be done ?
Not in any portable way. What problem are you trying to solve?
Perhaps there is an other solution barking up another tree.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?