`
javahigh1
  • 浏览: 1225421 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

VC2005报告的template编译错误.....faint!

 
阅读更多

昨天做基于策略的资源管理的时候碰到一个恶心的问题----编译错误. 这年头,编译错误能难倒人的还真不多见.不过越来越仗着编译器的功能强大,而不注意留心写代码时候的细心(尤其是改代码的时候)终究让我遭到了报应.
当时的代码如下:

 template <typename ResType> class TSimpleResCreator
{
public:
ResType* newInstance()
{
return ResType::newInstance();//ResType;
}

void deleteInstance(ResType* pRes)
{
ResType::deleteInstance(pRes);
}
};

template <typename ResType , typename _TCreator = TSimpleResCreator<ResType> >
class TBaseResMgr : public _TCreator , public IResManager
{

}; //出错的提示行

这样的代码虽然我的模板水平不是很高。但是还不至于写错的。但是我代码是在以前的基础上改的。改完了以后怎么编译都通不过。编译器提示TBaseResMgr的模板参数太多。。。。错误行是发生上面代码注明的那个地方。同样的代码拷贝到另外一个工程里却是好的。 让我郁闷坏了。 很少见过那一行出错的。。。
后来仔细检查了一下。最终发现这个类前面还定义了几个其他类。而其他类前面有TBaseResMgr的forward declaration....我给TBaseResMgr类加了策略。做了改动。却没改 forward declaration 。。。。
原来的forward declaration是这样的:
template <typename ResType > class TBaseResMgr
后来改成这样就OK了。
template <typename ResType , typename _TCreator = TSimpleResCreator<ResType> >
class TBaseResMgr


很是不了解,为什么VC2005要把错误行号报告在那一行。哪怕是把错误行号指向类的定义那一行也好。很是不解。不过错还是在自己。所以下面:
反思:
 改代码一定要细心。copy paste代码是万恶之源更要千万小心

分享到:
评论

相关推荐

    Boost.Asio C++ Network Programming.pdf

    not a task for the faint-hearted. Boost.Asio provides an excellent abstraction over it, making sure that with a minimal amount of coding, you can create beautiful client-server applications and have...

    Boost.Asio C++ Network Programming 1st 原版pdf by Torjo

    not a task for the faint-hearted. Boost.Asio provides an excellent abstraction over it, making sure that with a minimal amount of coding, you can create beautiful client-server applications and have ...

    电子设计大赛F题红外通信.docx

    First mainly with LM386 circuit chip music, send electrical signals, because the signals are faint, so need to pass a partial pressure type radio appropriate amplified signals, and through the LED ...

    数据结构实习2.4马踏棋盘/骑士游历/马的周游/Knight

    清华大学 严蔚敏版 数据结构题集 实习 2.4 马踏棋盘 C++编写, DEV_C++ ...PS PS: 比较经典的题目,不是太过无聊,不过一般都是递归搞定就OK了,理解栈的意义就达到目的了嘛,还一定要求非递归编写...faint.. - -|||

    数据结构实习1.4 双向循环链表实现长整数加减

    清华大学 严蔚敏版 数据结构题集 实习 1.4 长整数四则运算 C编写, DEV_C++ 编译器下运行通过 PS: 只实现了带符号加减,以应付作业. 纯应付作业,无实用价值... 纯用来赚资源分 ... 狂faint.. - -|||

    Agile.Android.1484297008

    Up until now getting JUnit testing up and running in Android was not for the "faint hearted." However, "now it's in Android Studio, there is no excuse," according to the author Godrey Nolan, president...

    Martin Harwit, Astrophysical Concepts 4th.pdf

    Universe have revealed themselves in the faint ripples marking the microwave sky. These ripples also document the first appearance of dark matter now known to have dominated the formation and ...

    比较精巧的数据库维护辅助工具

    &lt;faint_2 value=""&gt;&lt;/faint_2&gt;,但工具只取faint_1的value做为标题 所以使用时改下名就行了 Sql.xml 这里的每一个节点的name即是工具目录树的节点名字 这个节点代表要具体的执行sql了,执行exec的值 即然...

    Agile Android(Apress,2015)

    Up until now getting JUnit testing up and running in Android was not for the faint hearted. However, "now it's in Android Studio, there is no excuse," according to author Godfrey Nolan, president of ...

    iPhone Cool Projects pdf

    It moves on to Rogue Amoeba's Mike Ash explaining how to design a network protocol using UDP, and demonstrating its use in a peer-to-peer application—a topic not normally for the faint of heart, but...

    c++ 相关资料和手册。编程必备

    (2)c++refcard.pdf c++参考卡片,2页纸总结c++常用信息,就是加密了没法打印,有点faint (3)cpp-gcc-manual-4.4.0.pdf (4)gcc-manual-4.4.0.pdf 看名字就知道是啥了 (5)CppQuickRef.pdf 参考卡片,4页,可以打印 ...

    Fiona Fung and Proud Of You

    A man can work behind the scenes in a period of time , but not all his life in this way, and a ...A girl's appearance can be flat faint, but her life must not be flat faint. 一个很好的英语小演讲的模板。

    iPhone Cool Projects

    It moves on to Rogue Amoeba's Mike Ash explaining how to design a network protocol using UDP, and demonstrating its use in a peer-to-peer application—a topic not normally for the faint of heart, but...

    Agile Swift(Apress,2016)

    Up until now getting unit testing up and running in Swift was not for the faint-hearted. Thankfully now, there is no excuse other than a lack of information on where to get started. iOS developers ...

    ZJU_ACM_All_Anwer 搞编程的都知道的浙江大学A 题库.本书 集了所有经 Z 题解集,集合并附 Mathimaticsumerical algorithms 数值算法

    ZJU_Main 主页 下一页 ZJU 题型分类 文演整理版 2008-3-23 数论: 1007 Numerical Summation of a Series 简单题,还是蛮有意思的 1045 HangOver 简单题 ... 1049 I Think I Need a Houseboat 简单题 ...

    android手机开发书籍(英文版)

    android,android手机开发书籍,英文版的,最新版本。

    Log4j完全手册WORD版

    以log4j complete manual的pdf版本为模板转换的word文档,格式基本相同,没有太大的出入。此版本主要方便大家用软件取词。

    faint - The Face Annotation Interface-开源

    用于基于不同插件和过滤器类型的人脸检测和人脸识别的Java框架。 包括纯Java中的Eigenfaces,通过JNI进行的OpenCV检测,Betaface.com Web服务的集成,肤色过滤器,Adobe XMP Export和一个不错的GUI

    holiday-road-faint-dusk:由GitHub Classroom创建的holiday-road-faint-dusk

    纳什维尔的假日路 您和您的队友已与国家公园管理局签约,以构建一个应用程序,该应用程序使人们可以为自己所维护的美丽国家公园的旅行制定行程。 每次旅行的起点将是田纳西州纳什维尔,但目的地将是用户选择的国家...

    Programming Microsoft ASP.NET 4

    Open the book with Firefox (need install plugin). ... So the book is not appropriate if you have only a faint idea about ASP.NET and expect the book to get you started with it quickly and effectively.

Global site tag (gtag.js) - Google Analytics