Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Learn how to fix error: no instance of overloaded function matches the argument list.
Next
Answered
Zion Wang
  • 19
Zion Wang
Asked: May 18, 20222022-05-18T19:41:03+00:00 2022-05-18T19:41:03+00:00In: cpp

Learn how to fix error: no instance of overloaded function matches the argument list.

  • 19

. Advertisement .

..3..

. Advertisement .

..4..

I encountered the following problem in completing my work:

No instance of overloaded function matches argument list

Below is the code I ran:

#define _CRT_SECURE_NO_WARNINGS
 #include <iostream>
 #include <string>
 
 using namespace std;
 
 class String
 {
 private:
 char str[100]; 
 char cpy[100];
 public:
 
 static const char NULLCHAR = '\0';
 
 String()
 {
  str[0] = NULLCHAR;
  cpy[0] = NULLCHAR;
 }
 
 String(char* orig, char* cpy)
 {
  Copy(orig, cpy);
 }
 
 void Display()
 {
  cout << str << endl;
 }
 
 void Copy(char* orig, char* dest)
 {
 
  while (*orig != '\0') {
  *dest++ = *orig++;
  }
  *dest = '\0';
 
 
 
 }
 
 void Copy(String& orig, String& dest) 
 {
  Copy(orig.str, dest.cpy);
 }
 
 void Concat(char* orig, char* cpy)
 {
  while (*orig)
  orig++;
 
  while (*cpy)
  {
  *orig = *cpy;
  cpy++;
  orig++;
  }
  *orig = '\0';
 
 }
 
 void Concat(String& orig, String& cpy)
 {
  Concat(orig.str, cpy.cpy);
 }
 
 int Length(char* orig)
 {
  int c = 0;
  while (*orig != '\0')
  {
  c++;
  *orig++;
  }
  printf("Length of string is=%d\n", c);
  return(c);
 
 }
 };
 
 int main()
 {
 String s;
 
 s.Copy("Hello");
 s.Display();
 s.Concat(" there");
 s.Display();
 
 String s1 = "Howdy";
 String s2 = " there";
 String s3;
 String s4("This String built by constructor");
 s3.Copy(s1);
 s3.Display();
 s3.Concat(s2);
 s3.Display();
 s4.Display();
 
 
 system("pause");
 return 0;
 }

What’s causing it, and how can it be resolved in the “no instance of overloaded function matches the argument list“ in the cpp?

no instance of overloaded function matches
  • 2 2 Answers
  • 159 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    lyytutoria Expert
    2022-06-25T13:58:55+00:00Added an answer on June 25, 2022 at 1:58 pm

    The cause:

    Although you a constructor that has two parameters and a default one, there is not a constructor for your String type that just accepts one argument. Therefore, the error happens.

    Solution:

    To solve this problem, you need to specify a constructor which accepts an unique parameter and initializes the string.
    Another way is copying your Copy and Concat functions which you give an unique parameter into a String object as the  following:

    String Copy(char* orig)
    {
    // The identical copy logic you possess,
    // don't copy into "*here"
    }
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Léo Grandjean
    2022-05-25T20:56:28+00:00Added an answer on May 25, 2022 at 8:56 pm

    Your Copy and Concat function take two parameters. However, you only pass one parameter to them. Your code should look something like this if you want to copy them into String objects.

    String Copy(char* orig)
    {
     // Same copy logic you have, 
     // except copy into "*this"
    }
    • 11
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.