freelanceprogrammers.org Forum Index » C
(Query) Base and Derived class constructors and using macros
Joined: 24 Jan 2005
Posts: 3
(Query) Base and Derived class constructors and using macros
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 ( ) 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..
Take Care..
With Regards
RPrasad
Do you Yahoo!? Yahoo! Search presents - Jib Jab`s `Second Term`
Joined: 25 Jan 2005
Posts: 8
(Query) Base and Derived class constructors and using macros
Hey do you know something about dynamic cast .I think it can help.I am not sure.Kindly send in the code . Rag`s <pachhu274783@...> wrote:
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 ( ) 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..
Take Care..
With Regards
RPrasad
Do you Yahoo!?Yahoo! Search presents - Jib Jab`s `Second Term` To unsubscribe : programmers-town-unsubscribe@yahoogroups.com
Do you Yahoo!? Yahoo! Search presents - Jib Jab`s `Second Term`
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
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
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







