Solved

Method parameter problem

Posted on 2007-04-04
4
202 Views
Last Modified: 2010-04-01
Hello,

i have a problem with a pointer and need someone to explain me how to fix it. My code is the following:

      std::vector<char> v;
      peh.rebuild(v);

The method rebuild() has the following signature:  void rebuild(std::vector< byte > &vBuffer) const
Whenever i try to call the method the way i described above, i get the following error:
d:\...\patchengine.cpp(558) : error C2664: 'PeLib::PeHeaderT<x>::rebuild' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'std::vector<_Ty> &'. How do i  have to call the method so the above works?

Thank you.
0
Comment
Question by:b3n_
4 Comments
 
LVL 1

Expert Comment

by:rgavrilov
ID: 18855775
Does it work if you pass std::vector<byte> to the method, instead of std::vector<char>?
I would suspect that you have some implicit casting going on, that produces std::vector<byte>.
0
 
LVL 11

Expert Comment

by:DeepuAbrahamK
ID: 18856048
signature:  void rebuild(std::vector< byte > &vBuffer) -> byte here

std::vector<char> v; --should be-> std::vector<byte> v;

Otherwise passing the parameter looks alright

Best Regards,
DeepuAbrahamK
0
 

Author Comment

by:b3n_
ID: 18856081
if i put byte as a parameter it doesnt compile, i changed it to <unsigned char> and it works. i should have told you im using c++ so there is no such type as byte.

thanks.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 50 total points
ID: 18856095
The problem is that char is signed, and byte (which is probably just a typedef of unsigned char) is not ...
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question