|
-
December 21st, 2004, 10:42 AM
#3
Re: Strings to Objects
Marg if we consider it as Factory, then probably implementation will be like this
please correct me if some thing wrong this pattern design for the posted question.
class Abstract {
virtual void Object () = 0;
};
class AObject : public Absrtact {
void Object (char *str) {
strcpy (ostr,str);
}
private:
char *ostr ;
};
class facotry {
virtual AObject* FObject () = 0 ;
};
class Concretefactory : public factory {
AObject* FObject () {
return new AObject ;
}
};
main () {
Concretefactory *cf1 ;
AObject aobj;
aobj = cf1->Fobject () ;
aobj -> Object ("Raghu") ;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|