31 lines
465 B
C++
31 lines
465 B
C++
// 指针的引用
|
|
// 为指针取个别名,相当于'指针的指针'
|
|
#include <iostream>
|
|
#include <cstdlib>
|
|
|
|
using namespace std;
|
|
|
|
struct STU
|
|
{
|
|
int sid;
|
|
float score;
|
|
};
|
|
|
|
// 指针的指针
|
|
void set_score(STU **q, int sid, float score)
|
|
{
|
|
(*q)->sid = sid;
|
|
(*q)->score = score;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
STU *p = (STU *)malloc(sizeof(STU));
|
|
|
|
set_score(&p, 2, 98);
|
|
|
|
cout << "sid = " << p->sid << ", score = " << p->score << endl;
|
|
|
|
return 0;
|
|
}
|