当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > g++模板编译方法

Unix/Linux
基础篇:find技巧1
基础篇:find技巧2
对shutdown,halt,reboot,init的一点理解
grep的使用
多个文件函数互相引用的编译操作
SLES 相关的若干问题
精品推荐:命令大集合[分类整理]
红旗桌面版5.0(Code Name是Apatite)将在8月中旬发布第一个Snapshot版本
创建VLAN
VRRP
代理ARP
用iptables构建DMZ防火墙
netstat 使用详解
刚刚安装好php与apache,现将
外贸英语900句 之 价格Price
First use Linux
Linux下wu-ftpd的配置使用指南
Fc2下五笔输入法的问题
ProFTP配置文件
一步到位的 LAMP 安装脚本 (AMP部分)

Unix/Linux 中的 g++模板编译方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-15   浏览: 130 ::
收藏到网摘: n/a

机器版本 linux 2.4.30  ;   g++   3.3.4   g++ 对模板类编译的后,连接时,出现“undefined reference to `int f<long>(long&)'”。 文档代码结构 a.h ---- 定义模板 #ifndef __A__H
#define __A__H
template<typename T>
int f(  T &s);
#endif   a.cpp ---- 实现模板 #include"a.h"
template<typename T>
int f( T &s)
{
   return 0;
}   main.cpp ---- 调用模板方法处理 #include "a.h"
int main()
{
    long a;
    f<long> (a);
    return 0;
}   这个问题,是g++ “不够完善”引起,可以如下处理 1.将a.cpp内容,放到a.h中,去掉a.cpp,编译连接问题解决 2.如果还要 a.h 和 a.cpp,则要在main.cpp中,export --- g++ 估计不支持