Visual c++ 使用引用使函数返回C++中的不止一个值

Visual c++ 使用引用使函数返回C++中的不止一个值,visual-c++,Visual C++,我写了一个代码,用引用来计算圆的面积和周长 未解析的外部符号无效c_decl圆和 未解决的外部问题 重载函数的多个实例 我已经给出了下面的代码 #include<stdafx.h> #include<iostream> void circle(int,float,float); using namespace std; int main() { int r; float a=0.0,c=0.0; cout<<"Enter the rad

我写了一个代码,用引用来计算圆的面积和周长 未解析的外部符号无效c_decl圆和 未解决的外部问题 重载函数的多个实例 我已经给出了下面的代码

#include<stdafx.h>
#include<iostream>
void circle(int,float,float);
using namespace std;
int main()
{
    int r;
    float a=0.0,c=0.0;
    cout<<"Enter the radius:"<<endl;
    cin>>r;
    circle(r,a,c);
    cout<<a<<"\t"<<c<<endl;
    return 0;
}
void circle(const int &i,float &j,float &k)
{
    j=3.14*i*i;
    k=2*3.14*i;
}

请帮忙。谢谢这可能是你想要的

Circle函数需要位于main方法之上,以便编译器在调用它时知道它存在。 圆函数的j和k参数是点。指针是用。还使用从指针获取值

circler,&a,&c,此方法同时接收a和c的内存位置。然后将内存位置提供给指针。&获取内存位置,*获取实际值

无论如何,它似乎是这样工作的

#include<iostream>
void circle(int,float,float);
using namespace std;
void circle( int i,float *j,float *k)
{
    float s;
    *j=3.14*i*i;
    *k=2*3.14*i;
}

int main()
{
    int r;
    float a=0.0,c=0.0;
    cout<<"Enter the radius:"<<endl;
    cin>>r;
    circle(r,&a,&c);
    cout<<a<<"\t"<<c<<endl;
    return 0;
}

更改圆的正向声明。圆的正向声明与圆的定义不匹配。谢谢。我更正了它。但为什么它像float&a而不仅仅是float?我通常会忽略变量名并获得正确的输出