菜鸟笔记
提升您的技术认知

c noncopyable禁止拷贝类-ag真人游戏

noncopyable类和copyable类

/*
 * noncopyable.h
 *
 *  created on: 2018-6-10
 *      author: 
 */
#ifndef noncopyable_h_
#define noncopyable_h_
namespace ld{
class noncopyable
{
public:
    noncopyable() {}
    ~noncopyable() {}
private:  // emphasize the following members are private
    noncopyable( const noncopyable& );
    noncopyable& operator=( const noncopyable& );
};
class copyable  // emphasize the class is copyalbe
{
};
} // end of namespace ld
#endif /* noncopyable_h_ */

test

#include 
#include "noncopyable.h"
class a : public ld::noncopyable
{
public:
    int a=1;
};
class b : public ld::copyable
{
public:
    int b=3;
};
int main()
{
    std::cout<<"test noncopyable"<
网站地图