疑问(求助):如何用C4ROID把几个文件链接起来一起编译。。?
c4droid吧
全部回复
仅看楼主
level 5
十九海生 楼主
C++ prime plus 6th edition
第九章 编程练习第一题: 如何把golf.h golf.cpp 以及main.cpp这三个文件用C4DROID来链接编译。。?[泪]
头文件:
//golf.h -- for pe9-1.cpp
const int Len = 40;
struct golf
{
char fullname[Len];
int handicap;
};
// non-interactive version:
// function sets golf structure to provided name, handicap
// using values passed as arguments to the function
void setgolf(golf & g, const char * name, int hc);
// interactive version:
// function solicits name and handicap from user
// and sets the members of g to the values entered
// returns 1 if name is entered, 0 if name is empty string
int setgolf(golf & g);
// function resets handicap to new value
void handicap(golf & g, int hc);
// function displays contents of golf structure
void showgolf(const golf & g);
函数定义:
//golf.cpp
#include <iostream>
#include "golf.h"
#include <cstring>
void setgolf(golf & g, const char * name, int hc)
{
strcpy(g.fullname,name);
g.handicap = hc;
}
int setgolf(golf & g)
{
using namespace std;
cout << "请输入名字:";
if (cin.getline(g.fullname,40))
{
cin.get();
cout << "\n请输入难度级别:";
cin >> g.handicap;
return (1);
}
else
return (0);
}
void handicap(golf & g, int hc)
{
g.handicap = hc;
}
void showgolf(const golf & g)
{
using namespace std;
cout << "name: " << g.fullname << endl;
cout << "handicap: " << g.handicap << endl;
}
一个main函数:
//main.cpp
#include <iostream>
#include "golf.h"
int main()
{
using namespace std;
golf ann;
setgolf(ann, "Birdfree", 24);
showgolf(ann);
golf a[5];
for (int i = 0;i < 5; i++)
{
setgolf(a[i]);
}
for (auto & e : a)
showgolf(e);
return 0;
}
2014年09月16日 12点09分 1
level 9
长按编译键
2014年09月16日 13点09分 2
[乖]好的,我去试一下。。
2014年09月16日 13点09分
果然有用。。感谢大神。。[呵呵]
2014年09月16日 13点09分
level 13
Makefile
2014年09月16日 14点09分 3
[疑问]makeile是什么术语。。?我是在compile那里搞定了。。
2014年09月17日 12点09分
level 13
放在同一个文件夹里。
2014年09月16日 15点09分 4
[乖]不仅要放在同一个文件夹,还要一起编译。。
2014年09月17日 12点09分
level 12
makefile
2014年09月16日 15点09分 5
[真棒]
2014年09月17日 12点09分
level 2
我的也是[泪][泪][泪]
2017年01月16日 03点01分 7
[笑眼] 我都好久不用c++了。。
2017年01月16日 05点01分
1