gpt4 book ai didi

c++ - 项目组织的最佳方式是什么?

转载 作者:太空宇宙 更新时间:2023-11-04 03:03:10 25 4
gpt4 key购买 nike

<分区>

我需要开发一个简单的可移植 C++ 程序 Billing_Unit。它读取一些参数(电话号码等)并返回通话价格和剩余的免费分钟数。

我决定从标准输入获取 Billing_Unit 的数据,并将结果输出到标准输出。

我开发了两个测试单元:Test_Unit_Source 和 Test_Unit_Destination。

我决定组织我的节目单元的连续表演:

  1. Test_Unit_Source:从数据库中读取数据并将其放入 标准输出;
  2. Billing_Unit:从中读取标准输出 前一个单位,计算通话费用,其余免费 分钟,输出结果。
  3. Test_Unit_Destination:读取调用 成本和剩余的免费分钟,将其存储到数据库中。

    测试单位来源 |计费单位 | Test_Unit_Destination

简化的 Test_Unit_Source:

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>

#define SUCCESS_RESULT 0
#define ERROR_RESULT 1

using namespace std;

int main() {
signed char buf;

string Name_File;
ifstream inp_file;

inp_file.open("temp.txt",std::ios::binary);

if (!inp_file) return ERROR_RESULT;

do {
buf=inp_file.get();
cout<<buf;
} while (!inp_file.eof());

return SUCCESS_RESULT;
}

简化的 Billing_Unit - 它必须是可移植的:

#include <iostream>

#define SUCCESS_RESULT 0
#define ERROR_RESULT 1

int main() {
signed char var;
unsigned long res;//cents
signed char next_call;

while (!EOF_USERS) {
std::cin >> input_data;
...
//calculations
...
std::cout << result;
}

std::cout << EOF_USERS;

return SUCCESS_RESULT;
}

简化的 Test_Unit_Destination:

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>

#define SUCCESS_RESULT 0
#define ERROR_RESULT 1

using namespace std;

int main() {
signed char buf;

ofstream out_file;

out_file.open("out.txt",std::ios::binary);

if (!out_file) return ERROR_RESULT;

while (!EOF_USERS) {
cin >> buf;
out_file << buf;
}



return SUCCESS_RESULT;
}

其实Test_Unit_Source 和Test_Unit_Destination 可以合并为一个程序单元。这取决于我的决定。

我的项目组织得好吗?这个项目的最佳组织是什么?可能通过命令行为 Billing_Unit 设置输入参数会更好,但我不知道在这种情况下如何返回结果。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com