我在一個項目的同一組源文件下有兩個不同的.cpp文件(鏈接列表)。我嘗試運行一個名爲「customer」的鏈接列表文件,但它只運行另一個名爲「video」的鏈接列表文件。我如何運行「客戶」鏈接列表文件?如何運行多個源文件???需要幫助(C++代碼塊)
我的customer.cpp文件處於活動狀態,但它仍在運行「視頻」鏈接列表文件的程序。
基本上我試圖帶兩個單獨的客戶名單和另一個單獨的視頻列表。
但是,當我嘗試在customer.cpp選項卡下執行程序時,我以爲它應該運行,但它運行video.cpp文件...我在這裏丟失了什麼?
#include <iostream>
using namespace std;
struct video
{
chartitle[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;
^這是我nodestructure的視頻列表中的文件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;
^這是我對這些客戶的聯繫list.the customer.cpp中的文件。無論nodestructure有兩種在同一個項目下分離源文件。
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中最後的代碼,我調用所有功能customer.cpp中的文件...當我與詮釋主要(無效)最初嘗試,編譯器顯示在video.cpp和customer.cpp中聲明瞭「main」的錯誤,所以我嘗試將「main」改爲「mains」,然後顯示任何錯誤...我在這裏錯過了什麼?
你爲什麼複製和粘貼*完全相同的問題*這一個? http://stackoverflow.com/questions/5150047/when-i-have-two-cpp-files-from-the-same-set-of-source-files-in-codeblocks-how你被告知不要做到這一點之前:http://stackoverflow.com/questions/5128613/here-is-my-entire-code-for-a-double-linked-list-c-help-needed-dont-know-where – 2011-03-01 04:50:11