文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>几种参数传递问题(读c++ primer plus)

几种参数传递问题(读c++ primer plus)

时间:2010-09-28  来源:sunliming

1:用数组做参数传递

#include   <iostream>

#include <cmath>



struct polar
{

double distance;:

double angle;

};
struct rect
{
double x;
double y;
}

void rect_to_polar(const *pxy,polar *pda);
void show_polar(const polar *pda);

int main()
{

rect rplace;
polar pplace;

while (cin >> rplace.x >> rplace.y)
{
rect_to_polar (&rplace,&pplace);
show_polar(&pplace)
}
return 0;
}

void show_polar(const polar* pda)
{
    using namespace std;
    cout <<pda->distance;
    cout << pda->angle;
}

void rect_to_polar (const rect *pxy,polar *pda)

{
using namespace std;
pda->distance =
sqrt(pxy ->x+pda->y*pda->y);
}
调用函数时候,将结构的指针的地址而不是结构本身传递给他。

相关阅读 更多 +
排行榜 更多 +
火柴人战争血腥打击

火柴人战争血腥打击

飞行射击 下载
沉浸式射击比赛

沉浸式射击比赛

飞行射击 下载
银河世界

银河世界

飞行射击 下载