[問題] 有人可以幫忙偵錯嗎
( *[1m *[m 為色碼,可以按 Ctrl+V 預覽會顯示的顏色 )
( 未必需要依照此格式,文章條理清楚即可 )
遇到的問題: (題意請描述清楚)
不管我怎麼函式調整引數 都無法 compile
開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux)
Dev-C++
有問題的code: (請善用置底文標色功能)
這需要很多功能 我只是把其中的抽出來 還有我很新手 請不吝指教
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
struct question{
int type;
int a,b,c,r,ansc,ansr;
bool isCorrect;
};
void Print_Q(int,question);
int main()
{
int n,seed,l,u;//題數,種子,最小值,最大值
int i,j,k;
cout << "#questions=";
cin >> n;
question *N;
N=new question[n];
cout << "random seed=(0 to use time as seed)";
cin >> seed;
cout << "input[l,u]=";
cin >> l >> u;
Print_Q(u,*N);
system("pause");
return 0;
}
void Print_Q(int i,question *Q)
{
cout << i << endl;
}
補充說明:
重點在於Print_Q這個函式 我不管怎樣設定引數 都不能compile
有很多奇奇怪怪的宣告可以不用理會 Print_Q運算的也不用理會
(我只希望compile過 所以先隨便打了東西測試 函式會用到*Q)
要嘛就是不能連結 要嘛就是沒有定義函數
我看我朋友的main函式裡面寫 Print(i,Q); 函式void Print(int i,question *Q)
可以用 可是我自己測試還是不行
(不過我覺得挺神奇的 為什麼這樣可以compile過)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.115.182
※ 編輯: ernieyang09 來自: 140.116.115.182 (03/28 00:49)
推
03/28 00:49, , 1F
03/28 00:49, 1F
main裡面 Print_Q(u,*N) Print_Q(int i,question *Q)是
[linker error]undefined reference to 'Print_Q(int,question)'
Id return 1 exit status
main裡面 Print_Q(u,N) Print_Q(int i,question *Q)是
conversion from "question" to non-scalar type 'question' requested
main裡面 Print_Q(u,*N) Print_Q(int i,question Q)是
在這情況下可以 可是我函式裡面要打Q[i].a之類的就會錯誤
※ 編輯: ernieyang09 來自: 140.116.115.182 (03/28 00:55)
推
03/28 00:50, , 2F
03/28 00:50, 2F
推
03/28 00:53, , 3F
03/28 00:53, 3F
→
03/28 00:53, , 4F
03/28 00:53, 4F
感謝 可以了 可以說明一下這兩個東西嗎
教授都沒教指標就叫我們寫了(第三個作業了) 自己唸有很多東西容易MISS
※ 編輯: ernieyang09 來自: 140.116.115.182 (03/28 00:57)
推
03/28 00:59, , 5F
03/28 00:59, 5F
→
03/28 00:59, , 6F
03/28 00:59, 6F
→
03/28 01:00, , 7F
03/28 01:00, 7F
推
03/28 01:02, , 8F
03/28 01:02, 8F
→
03/28 01:02, , 9F
03/28 01:02, 9F
推
03/28 15:23, , 10F
03/28 15:23, 10F
→
03/28 15:24, , 11F
03/28 15:24, 11F
→
03/28 15:25, , 12F
03/28 15:25, 12F
→
03/28 15:26, , 13F
03/28 15:26, 13F
→
03/28 15:27, , 14F
03/28 15:27, 14F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章