I'm trying to do something like this:

public:
  ULONG dispatch(char *command, size_t length, Stream<T> *stream);

<< moderator edit: fixed code tags >>

Where Stream is a template. I can make the class I'm putting it in a template as well - no big deal, I just don't know how anyways. Here's all relevant code:

template <class T> class Stream
{
 private:
  T *service;

 public:
  Stream(T *s){ this->service = s; }
  ~Stream(void){ this->close(); }

  virtual ULONG send(char*, size_t);

  virtual ULONG printf(char*, ...);

  virtual ULONG close(void);
};

template <class T> class ConnectionDescriptor
{
 public:
  ULONG dispatch(char *command, size_t length, Stream<T> *stream);
};

Thank you in advance

Recommended Answers

All 3 Replies

Okay, you have code that compiles, presumably you've also run it and seen that it does what you want. So why ask a question that you already know the answer to? Were we supposed to read your mind to discover what your real issue is?

it doesn't compile, that's why I'm asking. I don't know the correct syntax for this. If you don't understand what I'm asking: I'm trying to send a class template type as an argument to a function. I can't know what the underlying implementation is (the T)

>it doesn't compile
Define ULONG, include a header that gives you size_t, and it will. If not, your compiler doesn't properly conform to the C++ standard. Post the errors you get. Tell us your compiler. It's unlikely that we all use the same setup that you do.

>If you don't understand what I'm asking
I know exactly what you're asking, please don't assume that I have no idea what's going on just because you don't. However, I can't help you because the code you posted is correct, and with the necessary framework around it, will work properly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.