Q:

C++ object with members for an asio get method

I want to implement a class in which members match this function:
int get(
  string &host_,
  string &port_, 
  string url_path,
  ostream &out_,
  vector<string> &headers, 
  unsigned int timeout
  )

I have this:
#include <string>
#include <vector>
#include <iostream>
#include <istream>
#include <ostream>
#include "Register.h"

using namespace std;

class Request : public Register {

private:
string *host;
string *port;
string *url;
ostream *out;
vector<string> *header;
unsigned int *timeout;

public:
Request() {
  this -> host = new string();
  this -> port = new string();
  this -> url = new string();
  this -> out = new ostream();
  this -> header = new vector<string>();
  this -> timeout = new int();
}

But I´m not able to instantiate it.  What's up with the ostream for example:
this -> out = new ostream();

I'm still new to c++ and now I´m completely confused, and I couldn't find the correct answer on Google.

A:

std::ostream is a base class for specific stream implementations, like std::ofstream, you cannot directly instantiate it.
In C++, unlike in Java, we don't allocate everything on the heap, but prefer value semantics:
/// Can be easily copied
class HoldSomething {
private:
    std::string name;
    std::vector<std::string> values;
public:
    /// constructors
    HoldSomething() : name(), values() {}
    explicit HoldSomething( const std::string& name ) :
        name( name ), values() {}
    /// modifiers
    void addValue( const std::string& val ) {
        value.push_back( val );
    }
...

