J
James Booker
Hi all - this should be a very easy question to you guys.
Say I have two classes, class1 and class2. In my application, class2
can't operate without a class1, as class1 performs communication over
the network, as a sort of abstraction layer.
Now I could create a class1, and a class2, and make every method of
class2 take a reference to my class1, but I'd like to be a bit
cleaner than this. What i'd like is for class2 to store a pointer to
class1 when it is initialised, but I'm not 100% sure about how to go
about it. Given this:
namespace myNameSpace
{
public class class1
{
//methods
}
public class class2
{
private class1 myclass1;
//methods
}
Won't that instantiate a new myclass1 when the myclass2 is created?
I've got a huge thick book in front of me, but the problem is I'm not
sure of the terminology i need to look up.
I don't want a class1 created when class2 gets created, is all I'm
worried about, since my application will have one 'master' class1,
because there might be class3, class4, which all use this abstraction
layer.
Any thoughs appreciated.
Thanks
James
Say I have two classes, class1 and class2. In my application, class2
can't operate without a class1, as class1 performs communication over
the network, as a sort of abstraction layer.
Now I could create a class1, and a class2, and make every method of
class2 take a reference to my class1, but I'd like to be a bit
cleaner than this. What i'd like is for class2 to store a pointer to
class1 when it is initialised, but I'm not 100% sure about how to go
about it. Given this:
namespace myNameSpace
{
public class class1
{
//methods
}
public class class2
{
private class1 myclass1;
//methods
}
Won't that instantiate a new myclass1 when the myclass2 is created?
I've got a huge thick book in front of me, but the problem is I'm not
sure of the terminology i need to look up.
I don't want a class1 created when class2 gets created, is all I'm
worried about, since my application will have one 'master' class1,
because there might be class3, class4, which all use this abstraction
layer.
Any thoughs appreciated.
Thanks
James