freelanceprogrammers.org Forum Index » C

(Query)-How to Invoke derived class constructor-from Base cl


View user's profile Post To page top
pachhu274783 Posted: Thu Feb 03, 2005 9:22 pm


Joined: 24 Jan 2005

Posts: 3
(Query)-How to Invoke derived class constructor-from Base cl
Dear friends,

I have a piece of program like this.

//Main.cpp

#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 ( ) macro
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 ( ) macro is invoking the derived
class constructors? If it is true how? What is the
purpose of using macro here?
Plz help me .


Thanks in advance..



Regards

RPrasad





__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
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