下面是我要做的:
#include <iostream>
void out(box boxx);
struct box {
char charr;
float floatt;
};
int main()
{
box boxx;
boxx.charr = 'f';
boxx.floatt = 2.5;
out(boxx);
}
void out(box boxx)
{
std::cout << boxx.charr << "\n" << boxx.floatt;
}
我想做一个函数,从一个结构打印数据。
将函数声明移动到结构后面。
#include <iostream>
struct box {
char charr;
float floatt;
};
void out(box boxx);
int main()
{
box boxx;
boxx.charr = 'f';
boxx.floatt = 2.5;
out(boxx);
}
void out(box boxx)
{
std::cout << boxx.charr << "\n" << boxx.floatt;
}