4 Replies - 1765 Views - Last Post: 27 December 2011 - 03:21 PM Rate Topic: -----

#1 adil.h  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 15-November 11

No instance of overloaded function (error with string::replace() func)

Posted 27 December 2011 - 02:47 PM

#pragma once

#include <iostream>
#include <string>
#include <math.h>
using namespace std;

static int encodeVL64(int i){
	string s = "";
	char res[6]; //assign the var res to a a char array - len6
	  int p = 0;
 int sP = 0;
 int bytes = 1;
 int negativeMask = i >= 0 ? 0 : 4;
 i = abs(i);
 res[p++] = (char)(64 +(i & 3));
 for (i >>= 2; i != 0; i >>= 6){
	 bytes++;
	 res[p++] = (char)(64 + (i & 0x3f));
 }
 int null = 0;
 res[sP] = (char)(res[sP] | bytes << 3 | negativeMask);
  string tmp =  string(res);
tmp.replace("/0", "");


}



I tried porting a VL64 encoding class over to C++ inside a function. However, when it comes to tmp.replace();, I get "no instance of overloaded function". I also get too few argument function calls.
I know why I get the argument error (it requires 4 arguments to be passed), but I'm not sure about the overloaded function error.
Can someone shed some light on why it's throwing this error?

Thanks, Adil

Is This A Good Question/Topic? 0
  • +

Replies To: No instance of overloaded function (error with string::replace() func)

#2 jimblumberg  Icon User is offline

  • member icon

Reputation: 5344
  • View blog
  • Posts: 16,679
  • Joined: 25-December 09

Re: No instance of overloaded function (error with string::replace() func)

Posted 27 December 2011 - 03:07 PM

Once you give the proper number of arguments this error should disappear.

Jim
Was This Post Helpful? 0
  • +
  • -

#3 adil.h  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 15-November 11

Re: No instance of overloaded function (error with string::replace() func)

Posted 27 December 2011 - 03:09 PM

It still occurs.
Posted Image
Could I be doing something wrong with regards to the argument passing?
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is offline

  • member icon

Reputation: 5344
  • View blog
  • Posts: 16,679
  • Joined: 25-December 09

Re: No instance of overloaded function (error with string::replace() func)

Posted 27 December 2011 - 03:16 PM

You need to pass the correct parameters to the function. See this link for std::string.replace().

In future post the code in code tags. I find the screen shot too hard to read.

Jim
Was This Post Helpful? 0
  • +
  • -

#5 adil.h  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 15-November 11

Re: No instance of overloaded function (error with string::replace() func)

Posted 27 December 2011 - 03:21 PM

It does work, miraculously. Seems that I did not need tmp.replace() :D. Thanks for the help though Jim.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1