Stack.h
----------------------------------------------
#pragma warning(disable:4786)
#include <vector>
using namespace std;class Stack  
{
public:
bool find(const string &elem) const;
private:
vector<string> _stack;
}
==============================================
Stack.cpp
----------------------------------------------
bool Stack::find(const string &elem) const
{
vector<string>::const_iterator end_it = _stack.end();
return (::find(_stack.begin(), _stack.end(), elem) != elem);
}
==============================================怎么::find会被认为是Stack::find呢?
----------------------------------------------
--------------------Configuration: Stack - Win32 Debug--------------------
Compiling...
Stack.cpp
F:\xlee\SourceCode\_VC6\Stack\Stack.cpp(59) : error C2039: 'find' : is not a member of '`global namespace''
F:\xlee\SourceCode\_VC6\Stack\Stack.cpp(59) : error C2660: 'find' : function does not take 3 parameters
Error executing cl.exe.Stack.exe - 2 error(s), 0 warning(s)

解决方案 »

  1.   

    一不小心又少copy了一行代码Stack.cpp
    ----------------------------------------------
    #include <algorithm>
    #include "Stack.h"bool Stack::find(const string &elem) const
    {
    vector<string>::const_iterator end_it = _stack.end();
    return (::find(_stack.begin(), _stack.end(), elem) != elem);
    }
      

  2.   

    return (::find(_stack.begin(), _stack.end(), elem) != elem);
    -------------------------------------------------------------
    return (find(_stack.begin(), _stack.end(), elem) != elem);
      

  3.   


    return (find(_stack.begin(), _stack.end(), elem) != elem);
    VC一样认为是Stack::find
    ---------------------------------------------------------------
    --------------------Configuration: Stack - Win32 Debug--------------------
    Compiling...
    Stack.cpp
    f:\xlee\sourcecode\_vc6\stack\stack.cpp(59) : error C2660: 'find' : function does not take 3 parameters
    Error executing cl.exe.Stack.exe - 1 error(s), 0 warning(s)
      

  4.   

    重载?我不是要Stack类里有两个find函数,我是要Stack类的一个find函数,调用#include <algorithm>中的find函数,这是《Essential C++》中的代码啊,原来Stanley B. Lippman写的书也这么差?或者 侯捷 是虚有其名???
      

  5.   

    是不是因为没有::find这样的函数,所以就用你的函数
      

  6.   

    #include <algorithm>
    这句添加没有?
      

  7.   

    哈,又是bluebohe(薄荷)兄不是这样的,如果我不写在类里面,就不会出这样的问题,请看下面的正确代码:main.cpp
    ------------------------------------------------------------
    #include <string>
    #pragma warning(disable: 4786)
    #include <vector>
    using namespace std;#include <algorithm>void find()
    {
    string a;
    vector<string> b;
    find(b.begin(), b.end(), a);
    }void main()
    {
    find();
    }
      

  8.   

    sorry
    std::find(………………);
      

  9.   

    用std::find(...)确实出来了,可是又出了其它问题,《Essential C++》的例子怎么这么多错啊!等一下再问!bluebohe(薄荷)兄,去帮我的帖子(此帖已结)
    http://expert.csdn.net/Expert/topic/2402/2402559.xml?temp=.8040277
    随便回个帖吧,我自己想再回,可以不能连续回3次,谢谢!
      

  10.   

    终于找出问题来了,含有Stack类的程序会报错,是因为没有#include <string>,下面的代码可以通过了,还有,上面的程序写错了一点[!= elem]应该改成[!= end_it]Stack.cpp
    ----------------------------------------------
    #include <string>
    #include <algorithm>
    #include "Stack.h"bool Stack::find(const string &elem) const
    {
    vector<string>::const_iterator end_it = _stack.end();
    return (::find(_stack.begin(), _stack.end(), elem) != end_it);
    }
      

  11.   

    spwnihao(面鱼) 和 carbon107(&lt;软件开发思想.h&gt;) 两位兄弟,不好意思了,你们没有看清楚题目,所以……下次叫老师打你们屁股,hehe