| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1044 人关注过本帖
标题:适配器stack的构造函数问题
取消只看楼主 加入收藏
hzz063
Rank: 3Rank: 3
来 自:横县百合
等 级:论坛游侠
帖 子:80
专家分:114
注 册:2010-1-27
结帖率:100%
收藏
 问题点数:0 回复次数:2 
适配器stack的构造函数问题
程序代码:
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
using namespace std;



int main(void)
{

    deque<int> deq(10,5);
    
    stack<int> sta(deq);//为什么提醒不能转换呢


    return 0;
}

编译通不过.....
搜索更多相关主题的帖子: stack 函数 构造 配器 
2010-08-11 09:26
hzz063
Rank: 3Rank: 3
来 自:横县百合
等 级:论坛游侠
帖 子:80
专家分:114
注 册:2010-1-27
收藏
得分:0 
提示:

--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
e:\练习文件\【c++】\main.cpp(18) : error C2664: '__thiscall std::stack<int,class std::deque<int,class std::allocator<int> > >::std::stack<int,class std::deque<int,class std::allocator<int> > >(const class std::allocator<int> &)' : cannot convert par
ameter 1 from 'class std::deque<int,class std::allocator<int> >' to 'const class std::allocator<int> &'
        Reason: cannot convert from 'class std::deque<int,class std::allocator<int> >' to 'const class std::allocator<int>'
        No constructor could take the source type, or constructor overload resolution was ambiguous
执行 cl.exe 时出错.

main.obj - 1 error(s), 0 warning(s)



我用vc6,  用别的编译器又可以通过哦.....

一切只因为喜欢。
2010-08-11 12:53
hzz063
Rank: 3Rank: 3
来 自:横县百合
等 级:论坛游侠
帖 子:80
专家分:114
注 册:2010-1-27
收藏
得分:0 
恩,找到这个:
     explicit stack(const allocator_type& _Al = allocator_type())
        : c(_Al) {}

其中:     typedef _C::allocator_type allocator_type;

一切只因为喜欢。
2010-08-11 17:30
快速回复:适配器stack的构造函数问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011943 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved