Boost logo

Boost Users :

From: Ilya Sokolov (fal_delivery_at_[hidden])
Date: 2007-07-13 04:14:22


> //cpeer.h
>
> #ifndef CPEER_H_
> #define CPEER_H_
>
> #include <string>
> struct CPeer
> {
> std::string name;
> };
> #endif /*CPEER_H_*/
>
> //cpeermanager.h
>
> #ifndef CPEERMANAGER_H_
> #define CPEERMANAGER_H_
>
> class CPeer;
>
> #include <boost/shared_ptr.hpp>
> #include <boost/scoped_ptr.hpp>
>
>
> class CPeerManager
> {
> public:
> CPeerManager();

+ ~CPeerManager();

> boost::scoped_ptr<CPeer> cp_; //error
> // boost::shared_ptr<CPeer> cp_; // ok
> };
>
> #endif /*CPEERMANAGER_H_*/
>
> //cpeermanager.cpp
>
> #include "cpeer.h"
> #include "cpeermanager.h"
>
>
>
> CPeerManager::CPeerManager():
> cp_ (new CPeer() )
> {
>
> }

+ // define a destructor at the point where CPeer is complete
+ CPeerManager::~CPeerManager()
+ {}

>
> //main.cpp
>
> #include "cpeermanager.h"
>
[snip]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net