LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



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

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


hiho@ll

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

greet@ll
 
Old 07-28-2005, 09:30 AM   #2
ewaltd
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, 09:50 AM   #3
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Original Poster
Rep: Reputation: 30
i have found this googling for dynamic class loading
http://www.linuxjournal.com/article/3687
 
Old 07-28-2005, 09:59 AM   #4
ewaltd
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 :-)
 
  


Reply


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 03:12 PM
scope of instantiation -> multiple classes purefan Programming 1 04-16-2005 06:51 AM
Dynamic Class Loading Problems dmnc Programming 11 07-22-2004 05:06 PM
problem on dynamic function call inside a class! antony_csf Programming 0 06-29-2004 11:15 PM
dynamic array in class help PTBmilo Programming 6 03-09-2003 03:35 AM


All times are GMT -5. The time now is 03:10 AM.

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