|
I had a similar problem, and what I found that I needed to do was typedef my iterator object type, or do a using namespace std .
With the typedef I usually do something like this:
typedef set<int> setInt;
typedef setInt::iterator iterSetInt;
And that solved my problems.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I have something to the effect of this:
<br />
typedef map<String, variable> list;<br />
list vars;<br />
<br />
class my_class {<br />
public:<br />
my_class() {}<br />
void function() {<br />
vars.insert(pair<String, variable>((String("hi"), variable(6)));<br />
}<br />
};
This compiles fine; no errors. It runs up until I call my_class.function() tries to insert and then it freezes. However, if I move the move the map declaration into function() and make it local, it runs fine. But doesn't do me any good and I lose the data when the function ends.
Anyone know why this is happening? Is this supposed to happen? Is there a way around it?
Thanks for any help you can give.
|
|
|
|
|
If the my_class memory has become trashed, then insert could fail in the manner you describe.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
the variable class is a little memory extensive. If you declare overloaded operators outside of the class (ex. bool operator==(variable var, variable other) ) does it count towards the size of the class? I don't think it does, I just want to be sure
|
|
|
|
|
vars.insert(pair<String, variable>(<font color=#ff0000>(</font>String("hi"), variable(6)<font color=#ff0000>)</font>); Try removing the extra pair of parentheses marked in red.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
i need those parentheses.
It works now. I moved things around and lowered the class size and it seems to be working now.
|
|
|
|
|
i have a bunch of CSplitterWindows, 2 CSplitterWindows and a CHorSplitterWindow, organized like this:
<br />
+----------------------------------------+<br />
| || |<br />
| || |<br />
| || |<br />
| || |<br />
| || |<br />
|========================================|<br />
| || |<br />
| || |<br />
| || |<br />
| || |<br />
| || |<br />
+----------------------------------------+<br />
with some hackery i made the two vertical splitters stay together, to simulate a 4 way splitter. the problem is when the vertical splitters are moved to the left, the left panes don't recieve WM_SIZE, and when the horizontal splitter is moved up, it doesn't send WM_SIZE to the upper pane. all windows recieve WM_SIZE properly if the splitters are moved right, or down. is this a glitch in ATL or a problem of mine? either way, how would i go about fixing it? i assume if its ATL's problem, i have to derive two new classes and send WM_SIZE from my new classes?
oops, diagram got messed up, here is the code i use to set up the panes:
m_HorSplitter->SetSplitterPane(SPLIT_PANE_TOP, m_TopSplitter->m_hWnd);
m_HorSplitter->SetSplitterPane(SPLIT_PANE_BOTTOM, m_BottomSplitter->m_hWnd);
m_TopSplitter->SetSplitterPane(SPLIT_PANE_LEFT, m_Views[0]);
m_TopSplitter->SetSplitterPane(SPLIT_PANE_RIGHT, m_Views[1]);
m_BottomSplitter->SetSplitterPane(SPLIT_PANE_LEFT, m_Views[2]);
m_BottomSplitter->SetSplitterPane(SPLIT_PANE_RIGHT, m_Views[3]);
|
|
|
|
|
|
Hello,
I have a byte array in dialog object on ATL project, and i want to draw the image that represent the bytes array to my dialog.
Threre is any Article that can help me to draw the picture to the client device context? becuase i did it, but i don't see any picture.
Any information about this issue will help...
Thank's alot,
Itay.
|
|
|
|
|
Hi,
Are you drawing in the WM_PAINT handler or just using a CClientDC inside some function? Maybe during dialog initialization?
You should draw in the WM_PAINT handler if you want your drawing to be permanent, otherwise the next time window is updated your drawing will be lost.
Paolo
------
Why spend 2 minutes doing it by hand when you can spend all night plus most of the following day writing a system to do it for you? - (Chris Maunder)
|
|
|
|
|
I did it inside the OnDraw function.
|
|
|
|
|
Hi Guys,
I have a small doubt..In the following code im creating a window and then displaying as modelless using ShowWindow..
<br />
CMyWindow wnd;<br />
RECT rect;<br />
rect.top=0;<br />
rect.left=0;<br />
rect.bottom = 0;<br />
rect.right = 0;<br />
wnd.Create( NULL,rect, _T("Hidden_Window"),WS_OVERLAPPEDWINDOW);<br />
wnd.ShowWindow(SW_HIDE);<br />
CMainDlg dlgMain;<br />
if(dlgMain.Create(wnd.m_hWnd) == NULL)<br />
{<br />
ATLTRACE(_T("Main dialog creation failed!\n"));<br />
return 0;<br />
}<br />
<big>dlgMain.ShowWindow(nCmdShow);</big><br />
<br />
MainDlg is a child of Wnd(which is hidden)..Now this works fine but the problem is that now i want it as Modal Dialog..So if i replace ShowWindow by DoModal
I get assertion failure saying that handle of created window is null..
So any idea..
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
I don't know if this applies to your code, but usually with modal boxes, the only thing you do is call .DoModal() . You don't create the window yourself, hence the ASSERT failure.
|
|
|
|
|
Netmeisters,
I am trying to do something which should be simple. Using Visual C++ I want to create a map containing an STL string as a key and my own type as a value.
#include <string>
#include <map>
#include <iostream>
using namespace std;
map<string,CReport>slips;
Then to add a pair to the map:
string str;
pair<map<string,CReport>::iterator, bool> ret =
slips.insert(map<string,CReport>::value_type(str,report));
But this produces a host of error messages that I've included below.
Can't figure these out at all.
Any assistance much appreciated.
Matthew Fleming
mgf@mcw.edu
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(138) : while compiling class-template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const std::string &) const'
with
[
_Ty=std::string
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(36) : see reference to class template instantiation 'std::less<_Ty>' being compiled
with
[
_Ty=std::string
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(19) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled
with
[
_Kty=std::string,
_Ty=CReport,
_Pr=std::less<std::string>,
_Alloc=std::allocator<std::pair<const std::string,CReport>>,
_Mfl=false
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(61) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,CReport,std::less<std::string>,std::allocator<std::pair<const std::string,CReport>>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(83) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,CReport,std::less<std::string>,std::allocator<std::pair<const std::string,CReport>>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(101) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,CReport,std::less<std::string>,std::allocator<std::pair<const std::string,CReport>>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(77) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,CReport,std::less<std::string>,std::allocator<std::pair<const std::string,CReport>>,false>
]
c:\Palm\dpCold\DpCGenCond.cpp(201) : see reference to class template instantiation 'std::map<_Kty,_Ty,_Pr,_Alloc>' being compiled
with
[
_Kty=std::string,
_Ty=CReport,
_Pr=std::less<std::string>,
_Alloc=std::allocator<std::pair<const std::string,CReport>>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2676: binary '<' : 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
|
|
|
|
|
Ummm... You sure the error is where you think it is? Try compiling the following sample (which works fine in VC++ 6.0):
#include <string>
#include <map>
#include <iostream>
struct CReport{};
using namespace std;
map<string,CReport>slips;
int main()
{
string str;
CReport report;
pair<map<string,CReport>::iterator, bool> ret =
slips.insert(map<string,CReport>::value_type(str,report));
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Well, if I comment out
pair<map<string,CReport>::iterator, bool> ret =
slips.insert(map<string,CReport>::value_type(str,report));
I don't see the error messages.
Maybe I should mention that this is part of a fairly complicated thing. It is part of a palm conduit lib which is linked against openssl libraries.
Matthew Fleming
|
|
|
|
|
Joaquín's example builds fine for me with VC.NET 7.0.
I'm not entirely sure, but I think that the compiler is failing to find a suitable 'operator<' for std::string (which is of course normally a typedef for std::basic_string< char >).
I can replicate your error by removing the #include <string> line. Are you sure you haven't actually got '#include <string.h>'?
Examining the preprocessed output (use the C++/Preprocessor/Generate Preprocessed File option) shows that std::string and std::basic_string are defined in the internal header file <xstring> but that the operators are defined in <string>.
Ensure that <string> is included, and you should be fine.
The overload of operator< that takes two basic_string parameters (with matching template arguments) in this implementation is a namespace-scope template function, defined at line 125 of <string>.
--
Mike Dimmick
|
|
|
|
|
Yes, you are right, the problem was a missing include. In this program I have to do some C style string handling, so I had #include <string.h>. I thought I also had #include <string>, but I didn't. Apologies to all for my stupidity, and thank you for your assistance.
Matthew Fleming
|
|
|
|
|
Mike Dimmick wrote:
I can replicate your error by removing the #include line. Are you sure you haven't actually got '#include '?
Yes, you are right, the problem was a missing include. In this program I have to do some C style string handling, so I had #include <string.h>. I thought I also had #include <string>, but I didn't. Apologies to all for my stupidity, and thank you for your assistance.
Matthew Fleming
|
|
|
|
|
Just in case it happens again:
You can see the instantiation stack of what's being compiled after the error message in the 'see reference' lines. This shows the function that VC had selected to instantiate for the previous one. Working back along this stack we see that it was trying to compile std::map< std::string, CReport, std::less< std::string >, std::allocator< blah > >::insert(). In trying to compile that, it needed to instantiate an internal class member std::_Tree< blah > etc. The compiler lists the lines at which it needed to instantiate something else. From this we can see that it needed to locate an operator< to compare two std::strings. From that I deduced that somehow the appropriate operator wasn't being found.
This is a big improvement over VC6, which doesn't tell you _why_ it's trying to locate such a routine.
--
Mike Dimmick
|
|
|
|
|
Netmeisters,
I am trying to do something which should be simple. Using Visual C++ I want to create a map containing an STL string as a key and my own type as a value.
#include <string>
#include
#include <iostream>
using namespace std;
map<string,creport>slips;
Then to add a pair to the map:
string str;
pair<map<string,creport>::iterator, bool> ret =
slips.insert(map<string,creport>::value_type(str,report));
But this produces a host of error messages that I've included below.
Can't figure these out at all.
Any assistance much appreciated.
Matthew Fleming
mgf@mcw.edu
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(138) : while compiling class-template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const std::string &) const'
with
[
_Ty=std::string
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(36) : see reference to class template instantiation 'std::less<_Ty>' being compiled
with
[
_Ty=std::string
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(19) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled
with
[
_Kty=std::string,
_Ty=CReport,
_Pr=std::less<std::string>,
_Alloc=std::allocator<std::pair<const std::string,creport="">>,
_Mfl=false
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(61) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,creport,std::less<std::string>,std::allocator<std::pair<const std::string,creport="">>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(83) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,creport,std::less<std::string>,std::allocator<std::pair<const std::string,creport="">>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(101) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,creport,std::less<std::string>,std::allocator<std::pair<const std::string,creport="">>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(77) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,creport,std::less<std::string>,std::allocator<std::pair<const std::string,creport="">>,false>
]
c:\Palm\dpCold\DpCGenCond.cpp(201) : see reference to class template instantiation 'std::map<_Kty,_Ty,_Pr,_Alloc>' being compiled
with
[
_Kty=std::string,
_Ty=CReport,
_Pr=std::less<std::string>,
_Alloc=std::allocator<std::pair<const std::string,creport="">>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2676: binary '<' : 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
|
|
|
|
|
What data type is report? I recommend std::pair.
Kuphryn
|
|
|
|
|
Hi, everyone!
Please look at the sample codes below:
Output:
--------
12
2
Null is appended!
0
--------
Source code:
--------
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
char input[] = "12\n3456789\n123456789";
char output [3];
istringstream is (input);
while (is.getline (output, sizeof (output), '\n'))
{
cout << output << endl;
cout << strlen (output) << endl;
if (0 == output [strlen (output)])
{
cout << "Null is appended! " << endl;
}
cout << unsigned int (output [strlen (output)]) << endl;
}
return 1;
}
--------
But when I change "char output [3];" to "char output [0xff];", the output
is OK! Tt is,
--------
12
2
Null is appended!
0
3456789
7
Null is appended!
0
123456789
9
Null is appended!
0
--------
I have made a reference to MSDN and failed to find any answers.
Who can explain the reason?
Thanks in advance,
George
|
|
|
|
|
3 characters isn't enough to hold the longer line, 255 is.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks, Tim buddie!
Can you explain me the internal reason why the
loop only executes one time when the sizeof
buffer is 3?
regards,
George
|
|
|
|
|