다음 코드를 수행하면 pure virtual function call 에러가 발생되면서 프로그램이 죽는다.





	class A
	{
	public:
		A() {
		}

		void intermediate_call() {
			// Bad: virtual function call during object destruction
			virtual_function();
		}

		virtual void virtual_function() = 0;

		virtual ~A() {
			intermediate_call();
		}
	};

	class B : public A
	{
	public:
		// override virtual function in A
		void virtual_function()
		{
			printf("B::virtual_function called\n");
		}
	};



	B myObject;

	// This call behaves like a normal virtual function call.
	// Print statement shows it invokes B::virtual_function.
	myObject.virtual_function();


+ Recent posts