C + + Error C2440: "Type conversion": Cannot convert from "Std::vector::iterator" to "

Source: Internet
Author: User

Original address: http://blog.csdn.net/onlyou930/article/details/5602654

An iterator for a ring-set of rings

Say this day is calm, miles of clouds, my mood good not to say, received orders to clean a area (write part of the code, which has been completed under the VC6 code to transplant to VC7 under), the way is very easy, with ' rice bid ' word is ' kaka ' ground! There was an error when it was almost finished.

Error C2440: "Type conversion": Cannot convert from "Std::vector<_ty>::iterator" to "Ppkghead"
With
[
_ty=byte
]

Error code Ppkghead Phead = (ppkghead) m_vpkgrecv.begin ();

Halo, under the VC6 can be compiled through AH! Let's see why not convert it? Look at it. The return value is Std::vector::iterator or Std::vector::const_iterator, at begin () Add a point to the back to see the iterator there is a iterator (sure is a ring set of rings) and add, subtract, [] and other operators, it is depressing how to convert it? I looked in the vector, and it turned out to be a class iterator, and there were a few functions inside.

Const_reference operator* () const
{//Return designated object


return (*_MYPTR);
}


const_iterator& operator++ ()
{//Preincrement
++_myptr;
return (*this);
}

const_iterator& operator--()
{//Predecrement
--_myptr;
return (*this);
}

It's so exciting to see that _myptr is the current pointer! Modify Code

Std::vector::iterator p = m_vpkgrecv.begin ();
Ppkghead Phead = (ppkghead) p._myptr;

Compile through, haha! Always do not understand why VC7 in the dot after P does not show this member! Another solution found on the web is ppkghead phead = (ppkghead) & (*m_vpkgrecv.begin ()); This cast is really strong, haha! I don't know, brothers who have a better plan!

After writing the program to look at the interface provided by CryptoAPI, inadvertently saw a function cryptcreatehash, what is this?? Continue to find, I stand to collapse, he he he ... incredibly support various hash operations, signature and key generation!! Look at it. Support Md2,md4,md5,sha,mac,rsa,dss,des,3des,rc2,rc4,ssl3,aes ... too much, almost including the various algorithms you know! What a big cotton candy! How do you apply these APIs?! Because there are too many things to introduce, here I take the point-and-MD5 algorithm as an example, first to get the handle of the key container of the specified CSP (no container to build itself), then you can create an empty hash object with Cryptcreatehash, Secondly, using crypthashdata to hash a piece of data, add it to the specified hash object, again set a hash object with Cryptgethashparam parameters, a MD5 operation of the process is complete, huh? Here is an example I wrote about MD5, please give us a lot of advice!

C + + Error C2440: "Type conversion": Cannot convert from "Std::vector::iterator" to "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.