恩 代码还是简单比较好 不过 害怕后面编码量过多了 造成与std命名空间或者gtk命名空间重复 所以放进自己的命名空间里面以防万一 前缀也是一样的 这个样子 应该还是要使用一个方式解决 比较好吧 interface 在c++里面 可以实现 但是不像java那样好用 不如不用~~ 个人看法 ^_^ 还是头文件直接使用 不要有继承关系比较实在 UI 和 协议 代码文件夹分开 方便以后的管理 如果协议库是独立的库文件的话 以后可以直接把项目提取出来 不用再纠结 也可以有所谓的 MVC 架构 不过 c\s一般只有两层哈 其实是半懂 在研究研究哈 ^_^ 在 2011年1月4日 下午1:17,纵横天下 <zhtx10@xxxxxxxxx>写道: > 感觉没啥用处,光增加了输入的麻烦,对于命名空间,会降低编译速度,启动速度 > 以及main函数管理的速度,输入也麻烦,对于代码还是简单为好,编 写和维护都 > 容易,最好还是平行,不要弄太多层次。 > > 于 2011年01月04日 11:30, Eros 写道: > > 还是我的废话一大堆~~~ 见谅 ^_^ > > > > 不如整体包含在一个命名空间里面吧 GNOME_QQ? > > > > 文件加上前缀 gqq_ 类加上前缀GQQ_ 全局变量也加上前缀 gqq_ > > > > 还有 把debug 宏和函数 独立出来吧~~ 这样debug的功能更加独立一点 > > > > 同时 global 里面是全局变量定义 > > > > 类型定义的话 这个我有一个疑问 gtkmm的变量类型不是与 gtk一样的么? > > > > 如果重新定义的话 还是要加上前缀 和 放在命名空间里面比较好吧 > > > > #ifndef _OL_DEBUG_H_ > > #define _OL_DEBUG_H_ > > > > #include <stdio.h> > > > > enum OlDebugLevel { > > OL_LOG_NONE = -1, > > OL_ERROR = 0, > > OL_DEBUG = 1, > > OL_INFO = 2, > > OL_N_LEVELS, > > }; > > > > #define ol_logf(level, ...) do {ol_log_printf (level, \ > > __FILE__, \ > > __LINE__, \ > > __FUNCTION__, \ > > __VA_ARGS__); } while (0) > > #define ol_log_func() do {ol_logf (OL_INFO, "%s\n", __FUNCTION__); } > > while (0) > > #define ol_debugf(...) do {ol_logf (OL_DEBUG, __VA_ARGS__); } while (0) > > #define ol_debug(...) do {ol_logf (OL_DEBUG, "%s\n", __VA_ARGS__); } > > while (0) > > #define ol_errorf(...) do {ol_logf (OL_ERROR, __VA_ARGS__); } while (0) > > #define ol_error(...) do {ol_logf (OL_ERROR, "%s\n", __VA_ARGS__); } > > while (0) > > #define ol_infof(...) do {ol_logf (OL_INFO, __VA_ARGS__); } while (0) > > #define ol_info(...) do {ol_logf (OL_INFO, "%s\n", __VA_ARGS__); } > > while (0) > > #define ol_assert(assertion) do {if (!(assertion)) { \ > > ol_logf (OL_ERROR, "assert %s failed\n", #assertion); \ > > return; \ > > }} while (0) > > #define ol_assert_ret(assertion, ret) do {if (!(assertion)) { \ > > ol_logf (OL_ERROR, "assert %s failed\n", #assertion); \ > > return (ret); \ > > }} while (0) > > > > void ol_log_printf (int level, const char *file, int line, const char > > *funcname, > > const char *fmt, ...); > > > > /** > > * @brief Sets the message level to be logged > > * > > * @param level The level of message to be logged. There are 4 > > levels:<br /> > > * OL_LOG_NONE: Log nothing > > * OL_ERROR: Log only messages with OL_ERROR > > * OL_DEBUG: Log messages with OL_ERROR and OL_DEBUG > > * OL_INFO: Log all messages > > */ > > void ol_log_set_level (enum OlDebugLevel level); > > > > /** > > * @brief Sets the file to store log messages. > > * > > * @param logfile The filename of the log file. if logfile is "-", it > > represents > > * standard output > > * @return Return 1 if succeeded, or 0 if failed. > > */ > > int ol_log_set_file (const char *logfile); > > > > #endif /* _OL_DEBUG_H_ */ > > > > 这个是 OSD Lyrics 的 debug 头文件 觉得很有参考价值 > > > > > -- 我只是在代码中爬行的一只虫子...