Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Invoice
- {
- public:
- virtual void printInvoice() = 0;
- };
- class clsInvoiceWithHeader : public Invoice
- {
- public:
- void printInvoice()
- {
- cout << "Hello Client - I am clsInvoiceWithHeader" << endl;
- }
- };
- class clsInvoiceWithoutHeader : public Invoice
- {
- public:
- void printInvoice()
- {
- cout << "Hello Client - I am clsInvoiceWithoutHeader" << endl;
- }
- };
- class FactoryInvoice
- {
- public:
- static Invoice * getInvoiceType( int inttype) ;
- };
- //static Invoice * invoice = nullptr;
- Invoice * FactoryInvoice::getInvoiceType( int inttype)
- {
- Invoice * i = nullptr;
- if( inttype == 1)
- {
- return (new clsInvoiceWithHeader());
- }
- if ( inttype == 2)
- {
- return (new clsInvoiceWithoutHeader());
- }
- else
- return nullptr;
- }
- int main()
- {
- Invoice* iv = FactoryInvoice::getInvoiceType(1);
- iv -> printInvoice();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement