Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-28-2005, 06:39 AM   #1
Registered: Oct 2003
Posts: 249

Rep: Reputation: 30
dynamic class instantiation in c++?


first i have to say i need to solve this problem using linux, but i think it's a more c++ related question than linux

what i need:
explanation: i know that templates can generalize the datatype used for a class
so the class can work with an int, string, char, pointers
simply with different data types
my problem is something similar
i need a template for instaniating a class
this means, i want a configuration file, which says which class i need to use for the job i have to do
something like a string to object converter ;-)

i thought about make a abstract class and inherit from this and instantiate the needed class using the string
but the point is, i don't know how (or if this is possible) instantiate a object where the only knowledge of which object type to use is my configuration string

i hope it's understandable

Old 07-28-2005, 08:30 AM   #2
LQ Newbie
Registered: Jul 2005
Distribution: SuSE 9.3 Pro and FC3
Posts: 17

Rep: Reputation: 0
From your explination it sounds like you are wanting to build an object factory.

The best advice I can give is to google on "factory design pattern" or "design patterns in C++"
Old 07-28-2005, 08:50 AM   #3
Registered: Oct 2003
Posts: 249

Original Poster
Rep: Reputation: 30
i have found this googling for dynamic class loading
Old 07-28-2005, 08:59 AM   #4
LQ Newbie
Registered: Jul 2005
Distribution: SuSE 9.3 Pro and FC3
Posts: 17

Rep: Reputation: 0
That is a nice article.

Specific to implementing a factory in C++ under linux.

Good find :-)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic class loading doesn't find my functions!? Thinking Programming 1 07-28-2005 02:12 PM
scope of instantiation -> multiple classes purefan Programming 1 04-16-2005 05:51 AM
Dynamic Class Loading Problems dmnc Programming 11 07-22-2004 04:06 PM
problem on dynamic function call inside a class! antony_csf Programming 0 06-29-2004 10:15 PM
dynamic array in class help PTBmilo Programming 6 03-09-2003 02:35 AM

All times are GMT -5. The time now is 05:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration