24小时热门版块排行榜    

查看: 903  |  回复: 4
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

黄小霞

铜虫 (小有名气)

[求助] 为何编不过?哪里错了?

#include
template demol;
template
class CSampleTemplate
{
        private:
                T t1;
                T2 t2;
        public:
                CSampleTemplace(T arg1, T2 arg2)
                {
                        t1=arg1+num;
                        t2=arg2+num;
                }
                void Write()
                {
                        std::cout<<"t1:"<                 }
                ~ CSampleTemmplate(void){}
};
int main(int argc, char* argv[])
{
        CSampleTemplate temp(1,2);
        temp.Write();
        return 0;
}
编辑错误为:ug--------------------
Compiling...
11.cpp
E:\1\11.cpp(2) : error C2991: redefinition of template parameter '__formal'
        E:\1\11.cpp(2) : see declaration of '__formal'
E:\1\11.cpp(2) : error C2059: syntax error : 'constant'
E:\1\11.cpp(2) : error C2501: 'demol' : missing storage-class or type specifiers
E:\1\11.cpp(14) : warning C4183: 'CSampleTemplace': member function definition looks like a ctor, but name does not match enclosing class
        E:\1\11.cpp(20) : see reference to class template instantiation 'CSampleTemplate' being compiled
E:\1\11.cpp(19) : error C2523: 'CSampleTemplate::~CSampleTemmplate' : destructor tag mismatch
        E:\1\11.cpp(20) : see reference to class template instantiation 'CSampleTemplate' being compiled
E:\1\11.cpp(11) : warning C4183: 'CSampleTemplace': member function definition looks like a ctor, but name does not match enclosing class
        E:\1\11.cpp(23) : see reference to class template instantiation 'CSampleTemplate' being compiled
E:\1\11.cpp(19) : error C2523: 'CSampleTemplate::~CSampleTemmplate' : destructor tag mismatch
        E:\1\11.cpp(23) : see reference to class template instantiation 'CSampleTemplate' being compiled
E:\1\11.cpp(23) : error C2661: 'CSampleTemplate::CSampleTemplate' : no overloaded function takes 2 parameters
Error executing cl.exe.

11.obj - 6 error(s), 2 warning(s)
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

黄小霞

铜虫 (小有名气)

引用回帖:
3楼: Originally posted by caoyjian at 2012-06-20 11:43:58
好吧 。。把你的程序运行了一遍
最主要的问题呢。。是你的构造函数打成了templace...而应该是template如果我没看错的话,这么久才看出来对不住。。
其次我的运行环境是vs2010,所以改成了iostream,屏蔽了demol和 ...

谢谢!你好仔细哦!
5楼2012-06-21 08:51:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 5 个回答

caoyjian

金虫 (小有名气)

【答案】应助回帖

感谢参与,应助指数 +1
可以问一下那个demol是干什么的么。。
诚意、正心、修身齐家治国平天下
2楼2012-06-20 11:15:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

caoyjian

金虫 (小有名气)

【答案】应助回帖

好吧 。。把你的程序运行了一遍
最主要的问题呢。。是你的构造函数打成了templace...而应该是template如果我没看错的话,这么久才看出来对不住。。
其次我的运行环境是vs2010,所以改成了iostream,屏蔽了demol和endl还有析构函数。。很久没用模板了,希望对你有帮助。。
诚意、正心、修身齐家治国平天下
3楼2012-06-20 11:43:58
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 今天基金会出结果吗?20260819 +9 kkkl_v 2026-08-19 9/450 2026-08-19 19:11 by 菜鸟遥感
[基金申请] 欢迎发来filecode的Mz6后的代码验证其规律 +53 医学老男孩 2026-08-13 118/5900 2026-08-19 18:14 by 医学老男孩
[基金申请] 今天放榜吗? +14 布布和一二 2026-08-19 15/750 2026-08-19 18:07 by gltch
[博后之家] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 PnssoZglMj3v 2026-08-19 3/150 2026-08-19 18:04 by oCMhZAsgNFoO
[考博] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +3 PnssoZglMj3v 2026-08-19 4/200 2026-08-19 17:54 by oCMhZAsgNFoO
[考博] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 PnssoZglMj3v 2026-08-19 5/250 2026-08-19 17:42 by oCMhZAsgNFoO
[基金申请] filecode=后面第一个是大写字母 +10 wangze12014 2026-08-14 12/600 2026-08-19 16:56 by 苦难博士
[教师之家] 为什么余额宝的年化利率越来越低?主要原因有哪些? +4 瞬息宇宙 2026-08-15 4/200 2026-08-19 16:23 by allmydream
[基金申请] 2027广东省杰青 +4 奶牛小黑 2026-08-15 10/500 2026-08-19 11:02 by wanfengnew
[基金申请] 朋友圈看到的 +6 wangzilk 2026-08-18 8/400 2026-08-19 10:55 by Haru815
[基金申请] 快农历七夕节了,轻松一下,男人悄悄话,女施主请不要进来。 +6 Tide man 2026-08-14 7/350 2026-08-19 09:56 by ZJTJZ
[基金申请] 什么时候开奖? +6 CrisMessi 2026-08-18 6/300 2026-08-19 08:06 by Equinoxhua
[基金申请] 重要消息,中午系统在维护 +10 yuleib84 2026-08-18 11/550 2026-08-19 07:30 by 羽毛枫f
[基金申请] 哪位老哥知道今年的国自然具体哪一天放榜? +13 Ldrop2023 2026-08-13 16/800 2026-08-18 12:25 by 淀粉搬运工
[基金申请] 93BebMhtakh前后11位开头都是大写 +4 且听虎啸 2026-08-17 5/250 2026-08-18 00:49 by 蔡棒棒菂
[基金申请] 感觉是下周放榜了 +6 angus9576 2026-08-17 11/550 2026-08-17 23:57 by angus9576
[基金申请] 今天系统多次维护,明天很可能放榜! +8 zju2000 2026-08-16 9/450 2026-08-17 12:20 by lmz0216
[精细化工] 招聘 金属平磨液,抛光液研发工程师 +3 小天0311 2026-08-14 3/150 2026-08-16 07:31 by H9PLUS
[基金申请] 各位道友,我要去昆明玩几天,回来见。 +7 Tide man 2026-08-14 8/400 2026-08-15 01:11 by arzu_hma
[基金申请] 重要来源:本周末出结果 +10 瞬息宇宙 2026-08-12 10/500 2026-08-13 15:46 by likettle
信息提示
请填处理意见