473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

factory methods.

why should factory methods be virtual in C++ ?
what would be the impact if they were not ?
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 19 '05 #1
7 3848
Aman wrote:
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 ?

Jul 19 '05 #2

"Aman " <am**@techie.com> wrote in message
news:88************************************@mygate .mailgate.org...
why should factory methods be virtual in C++ ?
So the correct subclass of object is created.
what would be the impact if they were not ?


The correct subclass of object might not be created.
Jul 19 '05 #3

"Aman " <am**@techie.com> wrote in message
news:88************************************@mygate .mailgate.org...
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
Jul 19 '05 #4

"Chris Theis" <Ch*************@nospam.cern.ch> wrote in message
news:bj**********@sunnews.cern.ch...

"Aman " <am**@techie.com> wrote in message
news:88************************************@mygate .mailgate.org...
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....


I'm starting to think this was a homework question, verbatim.
Jul 19 '05 #5
"Gianni Mariani" <gi*******@mariani.ws> wrote in message
news:bj********@dispatch.concentric.net...
Aman wrote:
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 ?

No, what about static factory methods? They can't be virtual.
Jul 19 '05 #6
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.

"jeffc" <no****@nowhere.com> wrote in message
news:3f********@news1.prserv.net

"Chris Theis" <Ch*************@nospam.cern.ch> wrote in message
news:bj**********@sunnews.cern.ch...

"Aman " <am**@techie.com> wrote in message
news:88************************************@mygate .mailgate.org...
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....


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



--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 19 '05 #7
Jason Spashett wrote:
"Gianni Mariani" <gi*******@mariani.ws> wrote in message

....

Can you fill in the dots from there ?


No, what about static factory methods? They can't be virtual.


What part of the fill-in-the-dots are you missing ?

Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products....
6
by: Boogie El Aceitoso | last post by:
Hi, I'd like to have a function factory that returns objects of a class hierarchy. What's the best way to deal with the fact that different subclasses will have different constructor arguments?...
3
by: Sebastian Faust | last post by:
Hi, I am currently reading the chapter about abstract factorys from "Modern C++ Design" and wondering how it would be possible to create an object which has a constructor with parameters. At the...
10
by: Chris Croughton | last post by:
What do people call their factory functions? 'new' is not an option (yes, it can be overloaded but has to return void*). The context is: class MyClass { public: // Factory functions...
6
by: BBM | last post by:
I have an object that has a fairly complex construction sequence, so I have written a dedicated "factory" class that invokes the constructor of my object class (which does nothing but instantiate...
2
by: Julia | last post by:
Hi, I have an application composed from layers like the following A --B ---C A is the top layer C uses an Abstract Factory to Create Concrete classes
10
by: Mark | last post by:
I have an abstract class, and a set of classes that inherit from my abstract class. The fact that it is abstract is likely irrelevant. I have a static factory method in my abstract class that...
3
by: Andy | last post by:
Hi all, I'm developing n-tier applications and I'd like some advice. I have my data layer, business layer, and application layers. The data layer uses a method similar to the one described...
2
by: DotNetGuy | last post by:
I have developed a data access layer in my web site application by using web client software factory and put it in my business module as a service. The question is: Is it a good option to reuse...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.