Click here to Skip to main content
15,949,686 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: organizing everything visible on screen Pin
Gerry Schmitz7-Aug-22 6:54
mveGerry Schmitz7-Aug-22 6:54 
GeneralRe: organizing everything visible on screen Pin
Greg Utas7-Aug-22 7:11
professionalGreg Utas7-Aug-22 7:11 
GeneralRe: organizing everything visible on screen Pin
Calin Negru7-Aug-22 18:18
Calin Negru7-Aug-22 18:18 
GeneralRe: organizing everything visible on screen Pin
Gerry Schmitz7-Aug-22 7:06
mveGerry Schmitz7-Aug-22 7:06 
GeneralRe: organizing everything visible on screen Pin
Calin Negru7-Aug-22 20:07
Calin Negru7-Aug-22 20:07 
GeneralRe: organizing everything visible on screen Pin
Greg Utas8-Aug-22 0:47
professionalGreg Utas8-Aug-22 0:47 
GeneralRe: organizing everything visible on screen Pin
Gerry Schmitz8-Aug-22 7:23
mveGerry Schmitz8-Aug-22 7:23 
GeneralRe: organizing everything visible on screen Pin
trønderen8-Aug-22 8:28
trønderen8-Aug-22 8:28 
GeneralRe: organizing everything visible on screen Pin
trønderen8-Aug-22 8:10
trønderen8-Aug-22 8:10 
GeneralRe: organizing everything visible on screen Pin
Mohsin Ali Shah 202222-Aug-22 3:48
Mohsin Ali Shah 202222-Aug-22 3:48 
AnswerRe: organizing everything visible on screen Pin
Member 150787168-Aug-22 16:17
Member 150787168-Aug-22 16:17 
QuestionSecuring oAuth Client Id and Secret Pin
Kevin Marois27-Jun-22 7:29
professionalKevin Marois27-Jun-22 7:29 
AnswerRe: Securing oAuth Client Id and Secret Pin
jschell23-Oct-22 11:17
jschell23-Oct-22 11:17 
Questioncode organisation Pin
Calin Negru31-Jan-22 7:36
Calin Negru31-Jan-22 7:36 
AnswerRe: code organisation Pin
Bohdan Stupak4-Feb-22 4:05
professionalBohdan Stupak4-Feb-22 4:05 
AnswerRe: code organisation Pin
Richard MacCutchan4-Feb-22 4:56
mveRichard MacCutchan4-Feb-22 4:56 
GeneralRe: code organisation Pin
Calin Negru4-Feb-22 8:48
Calin Negru4-Feb-22 8:48 
GeneralRe: code organisation Pin
jschell17-Feb-22 11:12
jschell17-Feb-22 11:12 
GeneralRe: code organisation Pin
Calin Negru19-Feb-22 1:39
Calin Negru19-Feb-22 1:39 
GeneralRe: code organisation Pin
jeron119-Feb-22 7:03
jeron119-Feb-22 7:03 
GeneralRe: code organisation Pin
Calin Negru19-Feb-22 8:10
Calin Negru19-Feb-22 8:10 
GeneralRe: code organisation Pin
Richard MacCutchan19-Feb-22 21:44
mveRichard MacCutchan19-Feb-22 21:44 
GeneralRe: code organisation Pin
Calin Negru25-Feb-22 9:41
Calin Negru25-Feb-22 9:41 
What is the default approach for creating objects using a factory? When one is creating several objects of the same class using a factory is the factory class retaining the objects as an array/std container and returning through a function a pointer to the object that has been created (which can be stored into an array/container outside the factory class)?

this is code for creating a single object
#include <iostream> 
using namespace std; 

class Vehicle { 
public: 
    virtual void printVehicle() = 0; 
    static Vehicle* Create(VehicleType type); 
}; 
class TwoWheeler : public Vehicle { 
public: 
    void printVehicle() { 
        cout << "I am two wheeler" << endl; 
    } 
}; 

  
Vehicle* Vehicle::Create() { 
        return new TwoWheeler(); 
} 
  
// Client class 
class Client { 
public: 
  
   
    Client() 
    { 
        
    } 

    ~Client() { 
        if (pVehicle) { 
            delete[] pVehicle; 
            pVehicle = NULL; 
        } 
    } 
    void BuildVehicle()
    {
     pVehicle = Vehicle::Create(); 
    }
    Vehicle* getVehicle()  { 
        return pVehicle; 
    } 
  
private: 
    Vehicle *pVehicle; 
}; 
  
 
int main() { 
    Client *pClient = new Client(); 
    pClient->BuildVechicle();
    Vehicle * pVehicle = pClient->getVehicle(); 
    pVehicle->printVehicle(); 
    return 0; 
} 


how should the modified version of main() look like if you want more than one vehicle to be created
GeneralRe: code organisation Pin
Richard MacCutchan25-Feb-22 22:17
mveRichard MacCutchan25-Feb-22 22:17 
GeneralRe: code organisation Pin
Calin Negru26-Feb-22 0:14
Calin Negru26-Feb-22 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.