C++ 中的析构函数,望大神解答

#include
using namespace std;
int i=0;
class Person{
public:
int age;
string name;
Person(int a){
age=a;
cout<<"创建了一个年龄为#"<<age<<" 的人"<<endl;
}
~Person(){

  i++;
cout<<"销毁了一个年龄为"<<age<<" 的人"<<""<<i<<endl;
}

private:
int sex,weight;

};
void getAge(Person p){

 cout<<"getAge():"<<p.age<<endl;
 }

void as(Person p)
{
cout<<"nicai"<

}
int main()
{
Person person(250);
Person person2(200);
getAge(person);
as(person);
return 0;
}#include
using namespace std;
int i=0;
class Person{
public:
int age;
string name;
Person(int a){
age=a;
cout<<"创建了一个年龄为#"<<age<<" 的人"<<endl;
}
~Person(){
  i++;
cout<<"销毁了一个年龄为"<<age<<" 的人"<<""<<i<<endl;
}

private:
int sex,weight;

};
void getAge(Person p){

 cout<<"getAge():"<<p.age<<endl;
 }

void as(Person p)
{
cout<<"nicai"<<p.age<<endl;
}
int main()
{
Person person(250);
Person person2(200);
getAge(person);
as(person);
return 0;
}

为什么撤销了两次,不是一个只撤销一次么

你每声明一个对象,都需要调用一次构造函数,最后需要各调用一次析构函数

你创建了person和person2两个对象,他们各有一次析构函数调用