-3

The compiler said that the method in the class is not found. Whole error message is could not found the function

common::base::CategoryIdCache::addNewCid(std::string, common::base::eSqlCatalog&, std::vector, std::allocator >, std::allocator, std::allocator > > >&, std::vector, std::allocator >, std::allocator, std::allocator > > >&)

the candidate is

common::base::CategoryIdCache::addNewCid(std::string&, common::base::eSqlCatalog&, std::vector, std::allocator >, std::allocator, std::allocator > > >&, std::vector, std::allocator >, std::allocator, std::allocator > > >&)

DraculaW
  • 435
  • 1
  • 5
  • 7
  • i didn't understand the question ? can you please elaborate a bit ? –  Jun 19 '13 at 09:20
  • The error message seems pretty clear to me. You're supposed to pass your first argument (string) as a reference (std::string&), rather than as a value (std::string) – Kippie Jun 19 '13 at 09:20
  • The error message is clearly related (he's passing `std::string`, candidate being `std::string&`) but hard to tell what's wrong without any code. – Skamah One Jun 19 '13 at 09:20
  • @Kippie and how does one pass a reference rather than a value? :) – juanchopanza Jun 19 '13 at 09:31
  • @juanchopanza by passing a variable and not a recently-constructed string object. show some code and people can try to help you... – Massa Jun 19 '13 at 09:54
  • @Massa I don't need help, thanks. But what you said doesn't make much sense. – juanchopanza Jun 19 '13 at 09:58

2 Answers2

3

There are a couple of reasons why this could be happening:

  • You're either implementing a function with a different signature
  • Or you attempt to bind a temporary to a non-const reference

So

struct X
{
    void foo(std::string& x);
};

//implementation
void X::foo(std::string x); //wrong - different signature

or

struct X
{
    void foo(std::string& x);
};

//
int main()
{
    X x;
    x.foo("some string");
}
Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625
0

Passing by reference means u're passing the address(reference) of the variable to the function while passing by value means u're copying the value contained at that instant by the concerned variable and then passing it to the function.

You must have declared prototype or the function in a different way as compared to the way you're passing the value.

user2500489
  • 11
  • 1
  • 5