I am a newbie of C++ and I have some question about the shared_ptr
I think the best way to explain it is with an example:
/*******beginning of CValue.h*************/
#ifndef TVALUE_H
#define TVALUE_H
template< typename tvalue >
class CValue
{
public:
CValue( tvalue value ) : value_(value) {};
private:
tvalue value_;
};
#endif
/****end*************/
/*****Type.h***********/
#ifndef TYPE_H
#define TYPE_H
#include
/*template< typename tvalue >
struct Type{
typedef boost::shared_ptr< CValue< tvalue > > pValue;
};*/
template
struct Type
{
typedef boost::shared_ptr< Value<T> > pValue;
};
#endif
/********end************/
what if I want to make it as a composition class?
by example
/***************example**********/
#include "Type.h"
#include "CValue.h"
template<typename T>
class DIP //digital image processing
{
public:
DIP();
virtual ~DIP();
shared_ptr < Type >createMediumFilter();
};
template<typename T>
DIP<T>::DIP()
{}
template<typename T>
DIP<T>::~DIP()
{}
template<typename T>
shared_ptr< Type > DIP<T>::createMediumFilter()
{
typename Type::pValue c(new mediumFilter< T >);
return c;
}
/*****************end**************/
I want to create the instance of mediumFilter like this in the main function
int main()
{
Type::pValue C(new Composition
);
Type::pValue D;
D = C->createCValue();
cout<<"system pause"<http://old.nabble.com/some-problems-about-shared_ptr-tp29674340p29674340.htm...
Sent from the Boost - Users mailing list archive at Nabble.com.