Overload function

hi i need to create to overload function i have the code done but do not know how to make them overload function. please help. your help would be much appreciate it.

#include <iostream>
#include <string>
#include <cstring>
#include <cctype>
using namespace std;

char *CapUp(char *sentence);
char CapUp(string&);


int main()
{
const int size = 500;
char user[size];

cout << "Enter at least two sentences, but do not use capital letters.(C-string)\n";
cin.getline(user, size);

cout << "\nHere are your sentences with beginning words capitalized:\n";

cout << CapUp(user);

cout << endl << endl;
string makeCap;
cout << "\nEnter at least two sentences, but do not use capital letters.(string object)\n";
getline(cin, makeCap);
cout << "\nHere are your sentences with beginning words capitalized:\n";
CapUp(makeCap);
cout << makeCap;
}

char *CapUp(char *sentence)
{
int length = strlen(sentence);
int i, j;

sentence[0] = toupper(sentence[0]);

for (i = 0; i < length; i++)
{
j = i;

if (sentence[i] == '.' || sentence[i] == '?' || sentence[i] == '!')
{
j++;
j++;
sentence[j] = toupper(sentence[j]);

if (sentence[j] == ' ')
{
j++;
sentence[j] = toupper(sentence[j]);
}
}
}
return sentence;
}
char CapUp(string& makeCap)
{

bool ifCap = false;

for (unsigned int i=0; i<makeCap.length();i++)
{

if (makeCap[i] == '.' || makeCap[i] == '?' || makeCap[i] == '!')
ifCap = false;

if ((ifCap==false) && (isalpha(makeCap[i])))
{
makeCap[i]=toupper(makeCap[i]);
ifCap = true;
}
}
}
You need to edit this post to show the source code format.
Topic archived. No new replies allowed.