Solved

Question on C++Design Pattern(Urgent)

Posted on 2006-11-23
1
266 Views
Last Modified: 2010-04-01
Hi Experts,

I have to do the following.  I am given a object X, and I want to convert them to different objects based on the data provided in the X object.  All the objects( B, C etc. ) that I wanted to create are derived from a common class A as below.

class X{ }; // given to me by another interface

class A{ };

class B: public A{ };
class C: public A{ };
class D: public A{ };

As I was reading of design patterns and thought I could use Factory pattern.  Is it suitable for my problem?  If so, can you please give a simplified example.....

for example, Here is a quick example of what I wanted to do......

class EmployeeInfo{  // corresponds to X
string name;
string password;
string project;
string training;
string salary;
string manager_name;
string manager_id;
int numTeamMembers;
};

class Person { };  // corresponds to A

class Employee: public Person{  // corresponds to B
string name;
string password;
string training;
};

class Manager: public Person  // corresponds to C
{
string salary;
string manager_name;
string manager_id;
int numTeamMembers;
};

Given EmployeeInfo , I want to be able to create Employee, Manager objects...

Thanks a lot.
0
Comment
Question by:ambuli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
thanesh earned 500 total points
ID: 18005839
Check out this example.
It should be easy to follow.
http://en.wikipedia.org/wiki/Abstract_factory_pattern#C.2B.2B
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Writing a parser for java language 4 102
Arduino EDI - Programming language 3 128
What is sub-make ? 2 107
DCT of  2D array using fftw in c++ 9 134
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question