?
Solved

Method parameter problem

Posted on 2007-04-04
4
Medium Priority
?
216 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 200 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

762 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