|
Well, the thing is, the iterators are incompatible. An iterator is not an index into the container; it's more like a pointer to a specific location. Each iterator is only valid for one container. If you try to compare two iterators pointing to two different containers, it will obviously not work.
Actually, I think it's great that the implementation complains that something's wrong (although the message isn't really obvious). You might have had a very hard to spot bug otherwise.
C# and C++ have a lot of things in common, but still they are quite different. If you are serious about learning it, I can recommend Stroustrup[^]'s The C++ Programming Language[^]. It worked for me
Florin Crisan
|
|
|
|
|
None that I know of. But you can always try boost::algorithm::string::split[^].
See also the example[^].
Boost[^] is a free, peer-reviewed collection of portable C++ source libraries, started by a number of members from the C++ standardisation committee (they've been joined by others in the meantime), aiming to establish "existing practice" and provide reference implementations so that Boost libraries are suitable for eventual standardization. (Yes, the words are from the site ) There is a nice Background Information page[^].
A Windows installer is available here[^].
Florin Crişan
|
|
|
|
|
I wanna create a screen scrapper for the web in WTL. But I'm having a hard time finding a class that will let me access a web url to do it. I know in C# theres WebRequest. and I was wondering how would I go about doing it?
|
|
|
|
|
ATL got some internet-related classes added recently (I forget if it was VC7 or 8). Maybe there's something there for you.
|
|
|
|
|
Hi All,
I have a ActiveX component created using VC++.Net and want to include that in a ATL service created in .Net. But I am not able to add that and use the methods and functions of the ActiveX. Please can someone tell me how to access that ActiveX using Visual Studio 2005.
Thanks
Alpa
|
|
|
|
|
Hi All
I have developed a snapIn.at run time I have an object of class CSnapInItem.
I need to extract the classname of that object that inherit CSnapInItem class at run time.
I have tried CSnapInItem* pItem
typeid(*pItem).name();
but its not wrking....throwing an exception..at run time,...plzz help me..hoe to get the class name at run time.
thanks in advance.
Rashmi
|
|
|
|
|
|
Also make sure your type is a polymorphic type (that is, it has at least one virtual function).
As a rule of thumb, always read the MSDN information (paying extra attention the fine print) when not sure about something.
This article[^] explains quite well how typeid works.
Florin Crişan
|
|
|
|
|
Hi Florin
Thanx a lot for ur response
Rashmi
|
|
|
|
|
Error 1 fatal error C1083: Cannot open include file: 'stdio': No such file or directory
has anyone ever encountered this error while trying to include <stdio> ?
also, it seems to ignore my #include <string> and #include <stddef>
I'm using VS2005 and this is not making sense anymore!
-- modified at 7:25 Friday 23rd November, 2007
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
"Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
|
|
|
|
|
Mustafa Ismail Mustafa wrote: has anyone ever encountered this error while trying to include ?
Never happened (hint: I use #include <stdio.h> )
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
You've probably tried #include <stdio>
You should use #include <stdio.h> (like CPallini suggested).
Or, if you want to be standard C++ compliant, you should use #include <cstdio> . Note that this will put every definition definiton in the std namespace.
But if you really want to use C++ (rather than C), you should use <iostream> instead of the C functions.
Still, printf("Value=%d", value) is more convenient than cout << "Value=" << value; . But it's still not type safe. Nor extensible. That's why you should use boost::format[^]
If you are only using C instead of C++: why?
Florin Crişan
|
|
|
|
|
Maybe because it is an alternative
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I created atl com application project and I add atl composite control with connection points support to it. when we build the project a dialog resource appears then I placed combo box on dialog resource. Now how can I add variable to the combo box control and how to customize it.
thanks
Viswanadh
|
|
|
|
|
Hi All
I've developed an MMCSnapin in ATL.I have to implement drag-drop for nodes.
for that I havr to handle MMCN_QUERY_PASTE,MMCN_PASTE,MMCN_COPY events
can anyone tell me how to handle these events...
any suggesstions are highly awaited....
thanks in advance...
Rashmi
|
|
|
|
|
HI,
A::a (EStationID eStnID, VARIANT *pvtConTypes)
{
::CComSafeArray csaConType;
CComVariant varContTypes;
csaConType.CreateOneDim(VT_BSTR,4);
CComBSTR bstrName("Sim_Model1");
CComBSTR bstrName1("Sim_Model2");
CComBSTR bstrName2("Sim_Model3");
CComBSTR bstrName3("Sim_Model4");
csaConType.PutElement((long)0,bstrName.Copy());
csaConType.PutElement(1,bstrName1.Copy());
csaConType.PutElement(2,bstrName2.Copy());
csaConType.PutElement(3,bstrName3.Copy());
*pvtConTypes = csaConType.Detach();
can anyone please tell whether memory leak will occur in this code how to solve it
|
|
|
|
|
This doesn't compile, never mind run, so it's not going to leak memory.
Rather than CComSafeArray , I think you meant COleSafeArray (which has CreateOneDim and PutElement methods), which is an MFC class...
Also, the first parameter to COleSafeArray::PutElement is a long* , not a long , so passing 0, 1, 2 or 3 isn't going to work - you need to have a long variable that you pass the address of:
long index = 0;
csaConType.PutElement(&index, bstrName.Copy());
index = 1;
csaConType.PutElement(&index, bstrName1.Copy());
index = 2;
csaConType.PutElement(&index, bstrName2.Copy());
index = 3;
csaConType.PutElement(&index, bstrName3.Copy()); Aside from all that, I don't think it has a memory leak if implemented correctly.
|
|
|
|
|
HI all,
I am using Atl server for my application .
I have to transfer a file from my web application to the client . I am using the following code. But the application is unable to transfer the file
HANDLE file=CreateFile("C:\\xyz\\outsachin.txt",FILE_ALL_ACCESS,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_FLAG_OVERLAPPED|FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if(m_spServerContext->TransmitFile(file,NULL,NULL,"File transfer",0,0,NULL
,0,NULL,0,HSE_IO_ASYNC|HSE_IO_DISCONNECT_AFTER_SEND))
{
m_HttpResponse<<"<br>File transferred succesfully m_spServerContext";
}
else
{
m_HttpResponse<<"<br>File transferred falied m_spServerContext";
}
if(m_HttpResponse.TransmitFile(file))
{
m_HttpResponse<<"<br>File transferred succesfully m_HttpResponse";
}
else
{
m_HttpResponse<<"<br>File transferred falied m_HttpResponse";
}
Please help me out..Thanks in advance
-- modified at 4:26 Tuesday 20th November, 2007
|
|
|
|
|
Hi,
I have one MFC Application and i want to provide 30 day trial version facility to my application. Can u suggest the best way of implementing this??
Thanks & Regards
swamy
|
|
|
|
|
swamy Narasimha wrote: I have one MFC Application and i want to provide 30 day trial version facility to my application. Can u suggest the best way of implementing this??
you have to maintain some secure place so that you place your restriction of trial version. you could use registry for same
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I am kinda very new to ATL and MFC programming i am kinda trying to control my stage motor connected to serial/com port using a sample software available online by activexperts.com it worked fine for abt month but now i guess the software a way to check evalution period which has expired so my software doesnt wrk anymore can anyone please help as to how i can work around this as i am a biomed engineer and really dont understand coding very well i have attached my code for refrence. It asl me to include 3 files i downloaded from their website.
void openport()
{
BSTR bstrTemp = NULL;
m_strDevice = "COM1";
CString strmotor;
ComPort->put_BaudRate( 9600 );
ComPort->put_StopBits ( asSTOPBITS_2 );
ComPort->put_DataBits (asDATABITS_8 );
ComPort->put_Parity ( asPARITY_NONE );
SysFreeString ( bstrTemp );
bstrTemp = m_strDevice.AllocSysString ();
ComPort->put_Device ( bstrTemp );
SysFreeString ( bstrTemp );
ComPort->put_ComTimeout( 200 );
ComPort->Open();
strmotor="SPEED X=3500 Y=3500 Z=20000";
writeport(strmotor);
DumpStageMotor(2);
strmotor= "ACCEL X=40 Y=40 Z=20";
writeport(strmotor);
DumpStageMotor(2);
strmotor= "WRITE X99=5000 Y99=5000";
writeport(strmotor);
DumpStageMotor(2);
strmotor= "JOYSTICK X-Y-Z-";
writeport(strmotor);
DumpStageMotor(2);
strmotor= "move x= 6500";
writeport(strmotor);
DumpStageMotor(2);
}
void closeport()
{
CString strmotor;
if( ComPort == NULL )
{
m_strResult = "Failed to load AComport.dll";
return;
}
m_strResult = "Please wait...";
ComPort->Close();
strmotor= "JOYSTICK X+Y+Z+";
writeport(strmotor);
DumpStageMotor(2);
}
void writeport(CString m_strCommand)
{
WCHAR wszTemp[ 1023 + 1 ];
BSTR pCommand;
CString cstrCommand;
INT i = 0;
if ( m_bComdata )
{
CString strTemp = m_strCommand;
strTemp.MakeUpper ();
strTemp = strTemp.SpanIncluding ( "ABCDEF 0123456789" );
while ( strTemp.GetLength () >= 2)
{
wszTemp [ i++ ] = strtol ( strTemp.GetBuffer ( 0 ), NULL, 16);
strTemp.TrimLeft ( "ABCDEF0123456789" );
strTemp.TrimLeft ( " " );
}
strTemp = "";
pCommand = SysAllocStringLen ( (OLECHAR FAR *) wszTemp, i );
ComPort->WriteBytes( pCommand );
}
else
{
pCommand = m_strCommand.AllocSysString ();
ComPort->WriteString( pCommand );
}
SysFreeString( pCommand );
}
CString readport()
{
BSTR pString;
CHAR szBuffer[ 16384 + 1 ] = {0};
BOOL bOpened;
if( ComPort == NULL )
{
m_strResult = "Failed to load AComport.dll";
return (m_strResult);
}
ComPort->get_IsOpened( &bOpened );
if( ! bOpened )
{
return (m_strResult);
}
if ( m_bComdata )
{
ComPort->ReadBytes ( &pString );
INT nLength = ::SysStringLen ( pString );
for ( INT n = 0; n < nLength ; n++ )
{
CString strTemp = "";
strTemp.Format ( "%02X ", pString [ n ] & 0xff );
m_strInput += strTemp;
}
}
else
{
ComPort->ReadString( &pString );
if( pString [ 0 ] != '\0' )
{
m_strInput += pString;
m_strInput += "\r\n";
}
}
SysFreeString ( pString );
return (m_strInput);
}
Dipen
|
|
|
|
|
sunny.rana wrote: I am kinda very new to ATL and MFC programming i am kinda trying to control my stage motor connected to serial/com port using a sample software available online by activexperts.com it worked fine for abt month but now i guess the software a way to check evalution period which has expired so my software doesnt wrk anymore can anyone please help as to how i can work around this as i am a biomed engineer and really dont understand coding very well i have attached my code for refrence. It asl me to include 3 files i downloaded from their website.
I would ditch the evaluation only software and just use MSCOMCtrl. Also, I think someone here wrote a COM port automation object in either the ATL or COM section of CodeProject. You could look that up too. Failing that, you could take the extreme measure of paying ActiveXperts the money they want, but the free software out there would make me reluctant to do so.
Nathan
|
|
|
|
|
Hi all!
I'm developing an standard-compliant STL associative container, and the biggest problem, by far, has been how to use the allocator template argument.
NB: I have chosen not to support alternative pointers.
I have two questions that I hope you can help me answer.
Question 1:
-----------
After having allocated a new node-object, why does one use value_allocator.construct() to construct the value instead of just passing it by assignment? I have checked out the SGI and GNU implementation of stl_tree.h, and they just use assignment for bool, size_type and pointer values, why not do the same or use placement new for other values? After all, one of the requirements for container elements is that they must be copyable and assignable.
... a possible answer could be "because construct may have wanted side-effects such as logging". If so, why only support the side-effects when constructing value_type and node_type?
Question 2:
-----------
Besides node-elements, I also employ the following struct:
struct{ link_type n; stack<my_enum> s;}
- After I have allocated new space for my struct, can I just do a struct_allocator.construct() on it, or am I supposed to only do a stack_allocator.construct() on the stack element contained?
Jens Rasmussen
-- modified at 10:42 Sunday 11th November, 2007
|
|
|
|
|
One question to start with - do you have a copy of the C++ Standard? That would probably explain the rationale for allocators better than anything else. It's $30 from ANSI[^] and can be very useful to have a copy of.
jens rasmussen wrote:
After having allocated a new node-object, why does one use value_allocator.construct() to construct the value instead of just passing it by assignment? I have checked out the SGI and GNU implementation of stl_tree.h, and they just use assignment for bool, size_type and pointer values,
bools, size_type and pointers can have no special semantics on assignment, as they're simple data. However, other objects can, as assignment should involve destruction as well as construction.
jens rasmussen wrote:
- After I have allocated new space for my struct, can I just do a struct_allocator.construct() on it, or am I supposed to only do a stack_allocator.construct() on the stack element contained?
the struct_allocator.construct() should call to stack_allocator.construct(), so should be OK, I guess.
|
|
|
|
|
Hi Stuart - and thanks for your reply!
Yeah - I probably have all the relevant books. The only part I think is missing from every explanation of Allocators, is how to use them as a library developer.
Personally, I think that the best explanation is given by Matthew H. Austern in:
http://www.ddj.com/cpp/184403759
Your answer regarding why one does not use assignment/placement new, was very adequate (and a little humiliating I might add ) - just what I needed to put it all into place!
Regarding your answer to my struct problem - I personally think that I must do a stack_allocator.construct() on the stack element and either just leave the simple data be, or if a value is provided, use assignment (It is exactly the same problem as when allocating nodes, only value_type is replaced by stack). I can't see how struct_allocator.construct() should be able to call stack_allocator.construct() - any comments?
Best regards!
Jens
|
|
|
|
|