Solved

Method parameter problem

Posted on 2007-04-04
4
198 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now