In C++ (Microsoft Visual Studio), I have: main_savitch_4::string::string(const char str[ ] = “”) in mystring.h and added to in mystring.cpp:
main_savitch_4::string::string(const char str[ ] = ""){
allocated = 0;
current_length = 0;
start = new char[0];
}, which defines the private variables.
I get the following errors:
c:\users\erice\documents\c++_2\lab04\rice_lab04_2\rice_lab04_2\mystring.cpp(13): error C2572: 'main_savitch_4::string::string' : redefinition of default parameter : parameter 1
1> c:\users\erice\documents\c++_2\lab04\rice_lab04_2\rice_lab04_2\mystring.h(88) : see declaration of 'main_savitch_4::string::string'
1>.
What exactly is going wrong??? I don’t understand what = means in a function description
The compiler is telling you that you have the default parameter in the declaration and definition of the function. Remove it from the definition:
It means you are providing a derfault parameter to a function. For example,
The above means you can call
foowithout a parameter: