我有两个不同的.cpp
一个项目的同一组源下的文件(链表)。我尝试运行一个名为“customer”的链接列表文件,但它只运行另一个名为“video”的文件。如何运行“客户”链表文件?
My customer.cpp
文件处于活动状态,但仍在运行“视频”链接列表文件的程序。
基本上我试图带来两个单独的客户列表和其他带有视频的单独列表。
但是当我尝试在 customer.cpp 选项卡下执行该程序时,我认为它应该运行该程序,但它运行的是 video.cpp 文件......我在这里遗漏了一些东西吗?
#include <iostream>
using namespace std;
struct video
{
char title[40],star1[20],star2[20],star3[20],star4[20],prod[20],dir[20],proco[40];
int copy;
video *next;
};
video *first = NULL, *current = NULL;
int optn = 0;
^这是我的视频列表 video.cpp 文件的节点结构
#include <iostream>
using namespace std;
struct customer
{
char f_name[20],l_name[20];
int acc_num;
customer *next;
};
customer *start = NULL, *pointer = NULL;
int option = 0;
^这是我的客户链接列表的节点结构。customer.cpp 文件。这两个文件位于同一项目下的两个单独的源文件中。
int main(void)
{
first = NULL;
current = NULL;
do
{
display();
cout << endl;
cout << "Choose an option: " << endl;
cout << "1. Move the current position forward once." << endl;
cout << "2. Move the current position backwards once." << endl;
cout << "3. Add a video at the beginning of the list." << endl;
cout << "4. Add a video at the current position of the list." << endl;
cout << "5. Add a video at the ending of the list." << endl;
cout << "6. Delete the first video from the list." << endl;
cout << "7. Delete the video at current position from the list." << endl;
cout << "8. Delete the last video from the list." << endl;
cout << "9. End program." << endl;
cout << endl << " >> " ;
cin >> optn;
switch (optn)
{
case 1 : currentfor();
break;
case 2 : currentbac();
break;
case 3 : addbeginning();
break;
case 4 : addmiddle();
break;
case 5 : addending();
break;
case 6 : deletebegin();
break;
case 7 : deletemiddle();
break;
case 8 : deleteend();
break;
}
}
while (optn != 9);
}
^这是我调用 video.cpp 文件的所有函数的代码。
int mains(void)
{
start = NULL;
pointer = NULL;
do
{
display_menu();
cout << endl;
cout << "Choose an option: " << endl;
cout << "1. Move the current position forward once." << endl;
cout << "2. Move the current position backwards once." << endl;
cout << "3. Add a customer at the beginning of the list." << endl;
cout << "4. Add a customer at the current position of the list." << endl;
cout << "5. Add a customer at the ending of the list." << endl;
cout << "6. Delete the first customer from the list." << endl;
cout << "7. Delete the customer profile at current position from the list." << endl;
cout << "8. Delete the last video from the list." << endl;
cout << "9. End program." << endl;
cout << endl << " >> " ;
cin >> option;
switch (option)
{
case 1 : current_forward();
break;
case 2 : current_backward();
break;
case 3 : add_beginning();
break;
case 4 : add_middle();
break;
case 5 : add_ending();
break;
case 6 : delete_beginning();
break;
case 7 : delete_middle();
break;
case 8 : delete_ending();
break;
}
}
while (option != 9);
}
^这是我调用 customer.cpp 文件的所有函数的最终代码...
当我最初尝试使用 int main(void) 作为 customer.cpp 时,编译器显示一个错误,指出 video.cpp 和 customer.cpp 中都声明了“main”,所以我尝试将“main”更改为“mains”,然后它没有显示任何错误...我在这里错过了什么?