作者ric2k1 (Ric)
看板EE_DSnP
标题Re: [问题] hw1.2.1
时间Sun Oct 7 23:44:59 2012
※ 引述《jackervator (jokerlin)》之铭言:
: 请问一下
: hw1.2.1.a里面的三个函数我可以放到1.2.1.b里面再定义吗?
: 这样一来
: 我1.2.1.a全部放宣告
: 1.2.1.b全部放定义
: 看起来比较顺眼(?)
: 其实主要原因是
: 如果我同时compile的话
: 然後我1.2.1.a三个函数是在class外另外宣告的话
: 最後的main
: 她会有ambiguous的情况(.a和.b都有 她不知道用哪个)
: 只是我在想说这样会不会违反题目
: 想来问一下@@
先确定一下你有没有清楚题目的规定 ---
1.2.1.a 应该会有三个档案:
==========================
hw1.2.p1a.h // to define class P1a with the prototypes of its member functions
hw1.2.p1a.cpp // to define class P1a's member functions in a .cpp file
hw1.2.p1a.main.cpp // is the main() for this subproblem (provided)
当你 "make p1a" 的时候,以上三个档案会被 compile, 产生 hw1.2.p1a 这个执行档
而 1.2.1.b 所定义的那些 functions 并不是 class P1a 的 member functions,
而是用来检查 memory addresses 的 global functions.
"make p1b" 只会 compile hw1.2.p1b.cpp 以及 hw1.2.p1b.main.cpp
不会 compile hw1.2.p1a.main.cpp
所以不会有你说的两个 main 的问题啊!!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.36.58.66
※ 编辑: ric2k1 来自: 114.36.58.66 (10/08 00:02)