[問題] 在struct中宣告function
想請問大家怎麼樣在struct 裡頭宣告 function
接著來使用這個function呢?
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
typedef struct F{
int l;
int(* printem) (string text );
}F;
int main(){
F a;
a.printem("123");
}
這是我的code 可以順利compile 但在run time會crash
似乎是因為memory access的問題, 請問大家是哪裡有誤呢?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.169.178.204
→
12/09 21:00, , 1F
12/09 21:00, 1F
→
12/09 21:00, , 2F
12/09 21:00, 2F
→
12/09 21:01, , 3F
12/09 21:01, 3F
→
12/09 21:05, , 4F
12/09 21:05, 4F
→
12/09 21:06, , 5F
12/09 21:06, 5F
推
12/09 21:11, , 6F
12/09 21:11, 6F
→
12/09 21:13, , 7F
12/09 21:13, 7F
推
12/09 21:14, , 8F
12/09 21:14, 8F
→
12/09 21:15, , 9F
12/09 21:15, 9F
推
12/09 21:16, , 10F
12/09 21:16, 10F
→
12/09 21:41, , 11F
12/09 21:41, 11F
→
12/09 21:41, , 12F
12/09 21:41, 12F
→
12/09 21:45, , 13F
12/09 21:45, 13F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章