Answer the question
In order to leave comments, you need to log in
How to fix c++ class constructor error?
I have a concatenation function which returns my own String class. But when I call it in main with the copy constructor, it throws the error "no instances of the 'String::String' constructor matching the argument list." The code is attached.
Call line in main:
The copy constructor itself:
String res(str.concat(str1));
String::String( String& str) {
size_t size = strlen(str.string_) + 1;
delete[]str.string_;
str.string_ = new char[size];
strcpy_s(str.string_, size, str.string_);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question