freelanceprogrammers.org Forum Index » C

(Query) Base and Derived class constructors


View user's profile Post To page top
pachhu274783 Posted: Wed Jan 26, 2005 11:41 am


Joined: 24 Jan 2005

Posts: 3
(Query) Base and Derived class constructors
Dear friends,

I have a piece of program like this.

//Main.cpp

//Macro with arguments
#define CONNECT(Port, Wire, name) Port(*this, Wire,
name)

CONNECT(I1, ci1, "And2 I1");

CONNECT(I2, ci2, "And2 I2");

CONNECT(O1, co1, "And2 O1");

//I1,I2 are objects of input class

//O1 is object of output class.

//ci1,ci2,co1 are objects of connector class

//Connector is an abstract base class



//port.h

class Port : public Connector

{

protected:

Port(Connector &, const char* = "Port");

// Only derived ports can be created.

};

class Input : public Port

{

public:

Input(Component &, Connector &, const char* =
"Input");

//This will use the two argument port constructor in
the definition

};

class Output : public Port

{

public:

Output(Component &, Connector &, const char * =
"Output");

//This will use the two argument port constructor in
the definition

};

Actually it`s a very big program.But due to space
restriction I have reduced the program .Hope it`s
clear to you. My doubt is I have a CONNECT ( )
function in my program. So that it would invoke the
port constructor (?Hope I am correct). But the port
constructor is having only 2 arguments. But the
derived classes Input and Output have two constructors
Input( ) and Output( ) with the same three arguments.
Whether the CONNECT ( ) function is invoking the
derived class constructors? If it is true how? What
is the purpose of using macro here?

Thanks in advance..



With Regards

RPrasad



__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help