factory methods.

A

Aman

why should factory methods be virtual in C++ ?
what would be the impact if they were not ?
 
G

Gianni Mariani

Aman said:
why should factory methods be virtual in C++ ?
what would be the impact if they were not ?

Why do you think you need a factory ?

Factories are usually used when you want to separate the implementation
from the interface.

Can you fill in the dots from there ?
 
C

Chris Theis

Aman said:
why should factory methods be virtual in C++ ?

Because a factory should be able to create different types of objects.
Probably you should think about the reason of using a factory once again.
what would be the impact if they were not ?
You'd have some more worries in your life....

Chris
 
J

jeffc

Chris Theis said:
Because a factory should be able to create different types of objects.
Probably you should think about the reason of using a factory once again.

You'd have some more worries in your life....

I'm starting to think this was a homework question, verbatim.
 
J

Jason Spashett

Gianni Mariani said:
Why do you think you need a factory ?

Factories are usually used when you want to separate the implementation
from the interface.

Can you fill in the dots from there ?
No, what about static factory methods? They can't be virtual.
 
A

Aman Angrish

heh heh,
no it's not a homework question !! (i'm lucky i don't get homework ).
just read this statement in Gamma (design patterns ) ,wanted to know
why.
Thanks for your inputs.
regards,
Aman.
 

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

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top