Hi all,
I am pretty new to Object Oriented programming so the question i am asking might be childish..geeks, pardon me :)

alright,
i have an interface with 5 methods.
Class A is implementing that interface.
Now Class B creates an instance of Class A and calls the methods.

The functions in the Interface all have single parameter of type "Socket".
It kinda looks stupid to pass this one parameter to all the methods.
Is there any way where i can pass it just once and use it??
Please find an example below

Class A
{
Public void Func1(Socket listener)
{}
Public void Func2(Socket listener)
{}
Public void Func3(Socket listener)
{}
Public void Func4(Socket listener)
{}
Public void Func5(Socket listener)
{}
}

Class B
{
Socket server = new Socket();
A instA = new A();
instA.Func1(server);
instA.Func2(server);
instA.Func3(server);
instA.Func4(server);
instA.Func5(server);
}

Thanks in advance
-deathdarts

Well you could have a variable in Class A that you set to be your socket, eg

Class A
{
 public Socket Server;
.
.
.
.
}

Class B
{
Socket server = new Socket();
A = instA = new A();
A.Server = server;
}

but id actually question in that quick mock, why you needed server at all in class B surely it should be in class A?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.