Polymorphic perfect binding and exception handling

#include<iostream>
using namespace std;

class MyArray
{
public:
	MyArray(int m_len);
	~MyArray();
public:
	class eSize
	{
	public:
		eSize(int len)
		{
			m_len11 = len;
		}
		virtual void printErr()
		{
			;
		}
	protected:
		int m_len11;
	};
	class eNegative :public eSize
	{
	public:
		eNegative(int len):eSize(len)
		{
			m_len11 = len;
		}
		virtual void printErr()
		{
			;
		}
	};
	class eZero:public eSize
	{
	public:
		eZero(int len):eSize(len)
		{
			m_len11 = len;
		}
		virtual void printErr()
		{
			;
		}
	};
	class eTooBig :public eSize
	{
	public:
		eTooBig(int len) :eSize(len)
		{
			m_len11 = len;
		}
		virtual void printErr()
		{
			;
		}

	};
	class eTooSmall :public eSize
	{
	public:
		eTooSmall(int len) :eSize(len)
		{
			m_len11 = len;
		}
		virtual void printErr()
		{
			;
		}

	};
protected:
private:
	int m_len;
	int *MySpace;

};

MyArray::MyArray(int m_len)
{
	this->m_len = m_len;
	
	if (m_len == 0)
		throw eZero(m_len);
	if (m_len <= 0)
		throw eNegative(m_len);
	if (m_len >= 1000)
		throw eTooBig(m_len);
	if (m_len <= 10)
		throw eTooSmall(m_len);
}
MyArray:: ~MyArray()
{
	if (MySpace != NULL)
	{
		delete [] MySpace;
		MySpace = NULL;
		m_len = 0;
	}
}
int main()
{
	try
	{
		MyArray a(-5);
		
	}
	catch (MyArray::eSize &e)
	{
		// cout << "len Size of:" << e.eSize ();
		e.printErr();
	}
	catch (...)
	{
	}
		cout << "hello..." << endl;
	system("pause");
	return 0;
}

  

Intelligent Recommendation

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) binding exception handling

I encountered an org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) exception how to deal with? Follow the steps below to perform one by one: Check whether the package nam...

Service explain the binding layer DAO exception handling layer

domain: Just define a javabean. dao: For the operation of the database, it is placed in dao layer, which is usually dao by the database, delete, change, and other operations. service: to complete the ...

With @ControllerAdvice and @ExceptionHandler to complete the perfect custom exception class processing and custom exception handling classes

@ControllerAdice literally means that the controller layer of recommendations, my understanding is that the controller layer returns suggested values, different abnormal returns when there is a differ...

c++ day 11 polymorphic binding

Polymorphism Literally means multiple forms, which generally appear in inheritance to rewrite functions of the same name. When calling member functions, different functions will be executed according ...

Java polymorphic dynamic binding and static binding

Foreword In the previous article "Detailed explanation of overwriting and reloading in Java"Introduces what is overwriting and overloading, how to understand the concept of distinguishing be...

More Recommendation

Java-polymorphic transformation exception case

Polypeptide transformation abnormal case dsf A parent class: Subclass 1: Subclass 2: Test class: Output: Dog eating bones Dog look door Exception in thread "main" java.lang.ClassCastExceptio...

Binding exception

This error is thrown when the project runs: Binding exception: First, let's see if the value of the namespace attribute of the mapping file corresponds to Dao. If it doesn't correspond, change it to t...

Exception handling

Article directory SEH Overview Instance SEH Overview SEH is an exception handling structure and an important data structure for exception handling mechanisms. Each SEH contains two DWORD pointers: the...

Remember that a DBCP2 connection is not recycled, the program is stuck, and the analysis process

I just changed to a new company recently. I want to optimize the previous code and improve the efficiency of task execution. I reviewed the previous code. There are many places to optimize. The compan...

Spring boot 2.5.3 Integration Spring Cloud Alibaba Built NaCOS Service Brake 'ServiceName' Is Illegal, Services IS Blank`

Version description Spring boot and Spring Cloud Alibaba have corresponding relationships. If you do not set the Maven coordinates according to the corresponding version number, you will cause a varie...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top