⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testoverload.h

📁 使用stl技术,(还没看,是听说的)
💻 H
字号:
#ifndef TESTOVERLOAD_H_INCLUDED
# define TESTOVERLOAD_H_INCLUDED

# include <string>

class NonVirtual
{
public:
   void set( const std::string &name_, int size_ = 10, int width_ = 12 )
   {
      name = name_;
      size = size_;
      width = width_;
   }

   std::string name;
   int size;
   int width;
};


class VirtualNonCopyable
{
public:
	VirtualNonCopyable()
	{
	}

   virtual void set( const std::string &name_, int size_ = 10, int width_ = 12 )
   {
      name = name_;
      size = size_;
      width = width_;
   }

   std::string name;
   int size;
   int width;

private:
	VirtualNonCopyable( const VirtualNonCopyable &other );
	void operator =( const VirtualNonCopyable &other );
};


class ValueHolder
{
public:
	ValueHolder()
	{
	}

	std::string name;

private:
	ValueHolder( const ValueHolder &other );
	void operator =( const ValueHolder &other );
};


class NonVirtualReturnValuePolicy
{
public:
   NonVirtualReturnValuePolicy()
   {
   }

   ValueHolder *set( const std::string &name_, int size_ = 10, int width_ = 12 )
   {
      name = name_;
      size = size_;
      width = width_;
	  value.name = name;
	  return &value;
   }

   std::string name;
   int size;
   int width;

private: // Should not be needed (ValueHolder is non copyable), but Pyste does not detect this
	NonVirtualReturnValuePolicy( const NonVirtualReturnValuePolicy &other );
	void operator =( const NonVirtualReturnValuePolicy &other );

private:
	ValueHolder value;
};


class VirtualReturnValuePolicy
{
public:
   VirtualReturnValuePolicy()
   {
   }

   virtual ValueHolder *set( const std::string &name_, int size_ = 10, int width_ = 12 )
   {
      name = name_;
      size = size_;
      width = width_;
	  value.name = name;
	  return &value;
   }

   virtual ValueHolder *set( int size_ = 10, int width_ = 12 )
   {
	  name = "default";
      size = size_;
      width = width_;
	  value.name = "default";
	  return &value;
   }

   std::string name;
   int size;
   int width;

private: // Should not be needed (ValueHolder is non copyable), but Pyste does not detect this
	VirtualReturnValuePolicy( const VirtualReturnValuePolicy &other );
	void operator =( const VirtualReturnValuePolicy &other );

private:
	ValueHolder value;
};





#endif // TESTOVERLOAD_H_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -