Macro, Polymorphism

D

D. Susman

Hi,

I wonder if there is a way to introduce polymorphic parameters to a
macro. What I'm trying to say is: Say, I have a macro X taking
argument of type A*. Let there be a B class deriving from class A. Can
I pass a B to the macro as a pointer to A?

(One might say, "use templates anyway". I am applying a memory pool
mechanism and wrapping new and delete with macros New and Delete
correspondingly)

Thanks.
 
I

Ian Collins

D. Susman said:
Hi,

I wonder if there is a way to introduce polymorphic parameters to a
macro. What I'm trying to say is: Say, I have a macro X taking
argument of type A*. Let there be a B class deriving from class A. Can
I pass a B to the macro as a pointer to A?
Macros lack any form of type system, they just perform substitutions.
(One might say, "use templates anyway". I am applying a memory pool
mechanism and wrapping new and delete with macros New and Delete
correspondingly)
OK then, why not provide your own new and delete operators?
 
F

Fabian Lenzen

OK then, why not provide your own new and delete operators?

Yeah, simply define "operator new(size_t)" and "operator delete()"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,797
Messages
2,569,646
Members
45,374
Latest member
VernitaBer

Latest Threads

Top