Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I kindly request your assistance in compiling this code and guidance on which functions and commands I should add to successfully achieve this. This is a part of the source code for a program I am working on, and a colleague mentioned that finding a solution for this will resolve the entire process, which is of great importance to me. I do not have much experience in compiling, so I am asking for your instructions, guidance, and assistance.

**I sincerely thank all of you in advance, as well as this website.

Best regards,**
C++
include

using namespace std;

void std::basic_string<>::_Rep::_M_clone(allocator *param_1,uint param_2)
{
    _M_clone(param_1,param_2);
    return;
}


What I have tried:

I tried to find the solution to compile code. Please help!
Posted
Updated 4-Oct-23 3:00am
v3
Comments
Richard Deeming 4-Oct-23 8:39am    
You seem to have forgotten to ask a question. Dumping an unexplained and seemingly incomplete code block on us and expecting us to be able to work out what the problem is, what error you're getting, what you have tried, and where you are stuck, is not going to work.
BernardIE5317 22-Oct-23 4:06am    
may i please inquire the C++ texts you have studied . i inquire because quite a bit of C++ code is missing for compilation w/o error . you may wish to consider re-reading .
OriginalGriff 22-Oct-23 4:41am    
"may i please inquire the C++ texts you have studied . i inquire because quite a bit of C++ code is missing for compilation w/o error . you may wish to consider re-reading ."

No idea - I started with C++ back in the early 90's, when I bought myself a copy of the Visual C++ V1.0 IDE which came with a two foot thick box of books, including C++ manuals. (That eventually evolved into the Visual Studio we know and love today.) That was probably when I moved from C to C++ but it might have been earlier - I spent most of the nineties drunk to a greater or lesser extent so the details are a bit fuzzy from this distance.

I'd start by changing the first line: include isn't a known C++ keyword, though #include is - but the latter expects to be told what to inlcude ...
 
Share this answer
 
Also, this line is problematic :
C++
void std::basic_string<>::_Rep::_M_clone(allocator *param_1,uint param_2)
according to the declaration, this is a void function that is a member of the std::basic_string class with an unspecified template type argument. Both of those incorrect. The class basic_string is part of the Standard Template Library (STL) and it is highly unlikely you are not actually adding a method to that class. It is more likely that you are returning that type and almost always, one uses the std::string type in user code. Within the function itself, you are calling another function of the same name. Either that is a base class method or it is just wrong. There are a few ways one can invoke the base class method of the same name. The one I prefer is to use the __super keyword.

If I make all of those assumptions, the code should look more like this :
C++
std::string _Rep::_M_clone( allocator *param_1, uint param_2 )
{
    return __super::_M_clone( param_1, param_2 );
}
Note: I avoid use the "using namespace xyz" whenever I can, which is almost always, and I never, ever use it in a header file. This is because a "using namespace" statement can not be undone and it is bad practice to force it on all consumers of a header file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900