title: C++ proper pointer member initialization
body: <p>I'm new to C++ here, coming from a Java background. I have a class prototype that sets up two private pointer object members. </p>
  
  <pre><code>class DriveController : Controller {
  
  public:
  
  DriveController(
      int8_t portTL_, int8_t portTR_, int8_t portBL_, int8_t portBR_, 
      double wheelSize_, double baseSize_);
  
  private:
  // Internal chassis controller
  okapi::ChassisControllerIntegrated *chassisController;
  okapi::AsyncMotionProfileController *chassisMotionProfiler;
  </code></pre>
  
  <p>Now, in my constructor for this class, I initialize these two variables using a factory design pattern that is provided to me by the API that I am using. This is the only real way to initialize these classes. </p>
  
  <pre><code>DriveController::DriveController(
      int8_t portTL_, int8_t portTR_, int8_t portBL_, int8_t portBR_, 
      double wheelSize, double baseSize) 
  {
      // Initialize port definitions
      portTL = portTL_;
      portTR = portTR_;
      portBL = portBL_;
      portBR = portBR_;
  
      // Create chassis
      auto chassis = okapi::ChassisControllerFactory::create(
          {portTL, portBL}, // Left motors
          {portTR, portBR}, // Right motors
          okapi::AbstractMotor::gearset::red, // torque gearset
          {wheelSize, baseSize} // wheel radius, base width
      );
      chassisController = &amp;chassis;
  
      auto profiler = okapi::AsyncControllerFactory::motionProfile(
          1.0, 2.0, 10.0, *chassisController);
      chassisMotionProfiler = &amp;profiler;
    }
  </code></pre>
  
  <p>I know I'm doing something wrong with the allocation of memory here, because when I try to access these member pointers in later functions that are called, the program errors with a "Memory Permission Error". I was looking into using unique_ptr to store the objects, as they manage life cycle well, however, since the only way to create the objects is through the factory initializer, I haven't been able to find a good way to construct the unique_ptr. </p>
  
  <p>What is the proper way to initialize these pointer members?</p>