Solved

Method parameter problem

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to copy an image file into clipboard C/C++? 1 248
Path to  STL Map header file 1 91
C++ Code Issue 4 47
keep track of class structure 1 51
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

738 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