Solved

Method parameter problem

Posted on 2007-04-04
4
213 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_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

705 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