最近刚刚开始学习c++,有点问题想请教,我写了一个有结构体作为函数的参数的程序,为什么调试的时候老是秒退啊~~??谢谢大神了!
#include <iostream>
#include <string>
using namespace std;
struct student
{
string name;
int age;
};
void function(student student)
{
cout<<student.age;
cout<<student.name;
}
void main()
{
student nihao;
cout<<"la:";
cin>>nihao.age;
cout<<"la:";
cin>>nihao.name;
function(nihao);
}
#include <iostream>
#include <string>
using namespace std;
struct student
{
string name;
int age;
};
void function(student student)
{
cout<<student.age;
cout<<student.name;
}
void main()
{
student nihao;
cout<<"la:";
cin>>nihao.age;
cout<<"la:";
cin>>nihao.name;
function(nihao);
}