魔幻手机1全集 电视剧:c++题一道 各位高手帮忙解决一下

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/05 19:06:00
create a struct with a single int data member,and two global functions,each of which takes a pointer to that struct.the first function has a second int argument and sets the struct's int to the argument value,the second displays the int from the struct.test the functions.

struct a
{
int data;

};
static void func1(a*p,int arg){p->data=arg;}
static void func2(a*p){cout<<p->data;}

就是让你建一个只包含一个整型数据(不防设为struct SingleInt 其中整数为iData)的结构体和两个函数,而两个函数必须有一个参数是结构体的指针,第一个函数(不防设为void SetInt(SingleInt *p,int iNewint) )还需要有第二个整型参数,其功能是将iNewint的值付给结构体,即p->iData=iNewint。
而第二个函数(不凡设为PrintInt(SingleInt *p))是显示结构体iData的值。并要让你编写代码测试这两个函数,其实就在main中用SingleInt *si定义一个这个结构体的指针,再用new初始化一下,执行SetInt(si,你输入一个整数)和PrintInt(si)就可以了

兄弟,我E文差,给个中文版行不?咱是中国人呢,中文还没学好呢!