//ջ����



//�ɱ������Զ������ͷţ���ź����IJ���ֵ���ֲ�������
//ע������  :  ��Ҫ���ؾֲ������ĵ�ַ��ջ�����ٵ������ɱ������Զ��ͷ�


#if 0





#include <iostream>

int * func(int b)  //�β�����Ҳ�����ջ��
{
	b = 100;

	int a = 10;    //�ֲ����� �����ջ����ջ���������ں���ִ����֮���Զ��ͷ�
	
	return &a;     //���ؾֲ������ĵ�ַ
}



int main()
{


	//����func�����ķ���ֵ
	int* p = func(1);
	std::cout << *p << std::endl;   //��һ�ο��Դ�ӡ��ȷ����������Ϊ���������˱���
	std::cout << *p << std::endl;   //�ڶ���������ݾͲ��ٱ���


	system("pause");

	return 0;


}





//����

//�ɳ���Ա�����ͷţ�������Ա���Ƿţ��������ʱ�ɲ���ϵͳ����
//��C++����Ҫ����new�ڶ��������ڴ�

#include <iostream>

int* func()
{
	//����new�ؼ��ֿ��Խ����ݿ��ٵ�����

	//ָ��  ����Ҳ�� �ֲ����� ������ջ�� �� ָ�뱣����������ڶ���

	int *p = new int(10);

	return p;
	

}

int main()
{
	//�ڶ�����������
	int *p = func();

	std::cout << *p << std::endl;
	



	system("pause");

	return 0;

}



#endif // 0


//�ܽ᣺
//���������ɳ���Ա���ٺ��ͷ�
//������������new�ؼ��ֽ��п����ڴ�