Re: Method should return list<>, instead returns BOOL, no error. Why not?
On 2 Mar 2007 11:59:24 -0800, CedricCicada@gmail.com wrote:
Greetings!
I have a class with a method that is declared to return a std::list<>
object, but instead it returns a BOOL value. However, no compiler
error is thrown. Why not?
This makes me think that there's some implicit conversion between a
long and a list<>, but that makes no sense to me.
Code below.
RobR
=========== TagNamer.h ===============
#include "opc_defs.h"
#include "ComString.h"
#include <list>
#include "IniEx.h"
typedef std::list<CCOMString> taglist;
typedef std::list<CCOMString>::iterator tag_iter;
class _OPC_EXPORT CTagNamer
{
public:
CTagNamer();
virtual ~CTagNamer();
// void ReadIniFile();
taglist GetTagList(CCOMString tagFileName);
private:
CIniEx m_iniEx;
CCOMString GetTagID(int baseNumber, const CCOMString& tagName);
CCOMString m_baseTemplate;
CCOMString m_globalTemplate;
CCOMString m_separator;
};
======== TagNamer.cpp ============
taglist CTagNamer::GetTagList(CCOMString tagFileName)
{
BOOL result;
return result;
}
That shouldn't happen, because all of list's single-argument ctors are
supposed to be declared explicit. Your example can be simplified into:
#include <list>
std::list<int>
f()
{
return 1;
}
This compiles for me in VC6 but not VC7.1 or VC8, so I guess you're using
VC6?
--
Doug Harrison
Visual C++ MVP