VC6.0 上C 的分离编译模式 哪里错了啊?

[复制链接]
查看11 | 回复2 | 2011-5-18 11:22:42 | 显示全部楼层 |阅读模式
//count.h
#ifndefCOUNT_H
#defineCOUNT_H

#includeiostream
#includestring

usingnamespacestd;

templateclassType
intcount(Type*,int,constType

#endif


//count.cpp
#include\"count.h\"


exporttemplateclassType
intcount(Type*a,intsz,constType
        for(inti=0;isz;i)
                if(a==which)
                        n;
                returnn;
}

//main.cpp
#include\"count.h\"

intmain(){
        doublea[]={10.,20.,30.,40.,50.,30.,70.,80.,30.};
        cout\"count(a,9,30.)shouldreturn3:\"count(a,9,30.)endl;

        intb[]={10,20,30,40,50,30,70,80,30};
        cout\"count(b,9,30)shouldreturn3:\"count(b,9,30)endl;

        charc[]={\'a\',\'a\',\'c\',\'a\'};
        cout\"count(c,4,\'a\')shouldreturn3:\"count(c,4,\'a\')endl;

        stringd[]={\"aa\",\"aa\",\"aa\"};
        cout\"count(d,3,\\\"aa\\\")shouldreturn3:\"count(d,3,string(\"aa\"))endl;

        stringe[]={\"bb\",\"aa\",\"aa\"};
        cout\"count(e,3,\\\"aa\\\")shouldreturn2:\"count(e,3,string(\"aa\"))endl;

        return0;
}
麻烦哪位大虾指点指点哪里错了啊?
回复

使用道具 举报

千问 | 2011-5-18 11:22:42 | 显示全部楼层
exporttemplateclassType
export去掉









<h4class=\"ask\">追问


除了在主函数中添加#include\"count.cpp\"还有什么办法吗
回复

使用道具 举报

千问 | 2011-5-18 11:22:42 | 显示全部楼层
没了,VC里面不是标准的C模式,所以你这种export模式的分离编译没法在VC里面实现。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行