Home > Back-end >  Wonderful work error
Wonderful work error

Time:11-10

This error is how to return a responsibility?
Function does not match?
 
The namespace shop_message {
The class object {
Protected:
Double attack_n;
Int price_b;
Double sheid_n;
Private:
String names;
Int level;
Tuple
Const get_all_object_message ()
{
Return make_tuple (names, price_b attack_n,
Sheid_n, level);
}
Public:
Bool is_in_shop;
Bool can_buy_it (const personal_message & amp; P)
{
Return p.g et_gold_n () & gt;=price_b;
}
Virtual tool * turn_to_tool ()=0;
Void buy_it ()
{
Is_in_shop=false;
}
Auto get_basic_message () - & gt;
Const decltype (get_all_object_message ())
{
Return get_all_object_message ();
}
};
Boolean operator==(object& One, object& Two)
{
The return one. Get_basic_message ()==two get_basic_message ();
}
The class basket {
Protected:
Int find_num (const object * & amp; This_o, const
Vector & To)
{
Int c=1;
For (const auto& P: to)
If (p.f irst==this_o)
Return the c;
The else
+ + c;
return 0;
}
Private:
String who_buy;
VectorVector Num_object;
Void new_num ()
{
Vector Vo;
for(int i=0; i<=my_buy. The size (); + + I)
{
if(! Find_num (my_buy [I], vo))
Vo. Push_back ({my_buy [I], 1});
The else
+ + vo [find_num (my_buy [I], vo) - 1]. The second;
}
Num_object=vo;
}
Public:
Pair Double> Net_price ();
Shopping_message get_recorde ();
Void add_item (const object * & amp; This_object);
Void delete_item (const object * & amp; That_object);
};
}

E: \ \ VS_2019_C private information + + final project \ \ space space battle project, experimental code. CPP In member function 'void shop_message: : basket: : new_num ()' :
750 31 E: \ \ VS_2019_C private information + + final project \ \ space space battle project, experimental code. CPP [Error] no matching function for the call to 'shop_message: : basket: : find_num (shop_message: : object * & amp; , STD: : vector & amp;) '
750 31 E: \ \ VS_2019_C private information + + final project \ \ space space battle project, experimental code. CPP [Note] candidate is:
730 8 E: \ \ VS_2019_C + + private information battle project \ \ space space battle project, experimental code. CPP [Note] int shop_message: : basket: : find_num (const shop_message: : object * & amp; The const STD: : vector & amp;)
730 8 E: \ \ VS_2019_C + + private information battle project \ \ space space battle project, experimental code. CPP [Note] no known conversion for argument 1 from '__gnu_cxx: : __alloc_traits & lt; STD: : allocator : : value_type (aka shop_message: : object *} 'to' const shop_message: : object * & amp; '
753 33 E: \ \ VS_2019_C private information + + final project \ \ space space battle project, experimental code. CPP [Error] no matching function for the call to 'shop_message: : basket: : find_num (shop_message: : object * & amp; , STD: : vector & amp;) '
753 33 E: \ \ VS_2019_C private information + + final project \ \ space space battle project, experimental code. CPP [Note] candidate is:
730 8 E: \ \ VS_2019_C + + private information battle project \ \ space space battle project, experimental code. CPP [Note] int shop_message: : basket: : find_num (const shop_message: : object * & amp; The const STD: : vector & amp;)
730 8 E: \ \ VS_2019_C + + private information battle project \ \ space space battle project, experimental code. CPP [Note] no known conversion for argument 1 from '__gnu_cxx: : __alloc_traits & lt; STD: : allocator : : value_type (aka shop_message: : object *} 'to' const shop_message: : object * & amp; '

The function of the parameter is not match?

CodePudding user response:

Find_num parameter types do not match, into find_num (const object * this_o, const
Vector & Next, try to) const object * & amp; This_o, the feeling is so strange

CodePudding user response:

reference 1st floor wxf54318 response:
find_num parameter types do not match, into find_num (const object * this_o, const
Vector & Next, try to) const object * & amp; This_o, feel good strange

Thank you, really solve,
But why would practice according to my previous errors?
Pointer reference function declarations compiler is not an error

CodePudding user response:

See "the essence of c + + programming tutorial" P38 lightning: why can't a pointer to read-only entity assigned to (or to) write entity variable (or parameter), why can't a pointer to the variable entities assigned to the variables passed a value (or to) stable entity (or parameter), the function parameters of your original procedure is const object * & amp; This_o pointer, and arguments my_buy [I] is a writable object *.
  • Related