Click here to Skip to main content
15,896,154 members
Articles / Programming Languages / C++

Using Class Templates with Fake Parameters in Derived Classes.

Rate me:
Please Sign up or sign in to vote.
3.70/5 (7 votes)
21 Aug 20079 min read 51.5K   121   14  
An article provide new C++ idom to avoid code duplication.
#include "dataReader.h"
//DataReader.cpp
#include <assert.h>
// ---------------------------------------------------------------------------
// abstract class IDataReader
// ---------------------------------------------------------------------------
IDataReader::IDataReader() {}
//virtual
IDataReader::~IDataReader() {}

 IDataReader::IDataReader(const IDataReader&){}
// ---------------------------------------------------------------------------
IDataReader::IDataReaderPtr
IDataReader::clone() const
{
  doClone();
  IDataReaderPtr p = doClone();
  assert(typeid(*p)==typeid(*this)&&"doClone incorrectly overriden");
  return p;
}
// ---------------------------------------------------------------------------
bool 
IDataReader::read( VecString& outs)
{   
  return doRead(outs);
}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions