String replacement help

in the code below.....I'm getting 4 errors (2 for the same line)

1.) expected constructor, destructor, or type conversion before '.' token

2.) expected `,' or `;' before '.' token

I CANNOT MESS WITH ANYTHING BELOW THE "INT MAIN"!

What do these errors mean?

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

/* Will find and replace the given sub-string within
* the user provided string with the new sub-string.
*
* Require: user_string contains sub_string
* Ensure: user_string !contains sub_string &&
* user_string contains new_sub_string
*/
void replace(string& user_string,
const string& sub_string,
const string& new_sub_string);
str.replace(DEFAULT_NAME _LAST, " ") <-----------2 errors
cout << employee_tag.replace << endl;
str.replace(DEFAULT_NAME_FIRST, " ") <-----------2 errors
cout << employee_tag.repalce << endl;

int main() {

// Default Employee name on tag
const string DEFAULT_NAME_LAST("{DEFAULT_NAME_LAST}");
const string DEFAULT_NAME_FIRST("{DEFAULT_NAME_FIRST}");

// to hold string input from employee
string buffer("");

// Employee's ID Tag
string employee_tag("* EMPLOYEE: \n");
// add employee's last name first
employee_tag.append("* " + DEFAULT_NAME_LAST + ",\n");
employee_tag.append("* " + DEFAULT_NAME_FIRST + "\n");

// ask the employee for their first name
cout << "Hello new employee!" << endl;
cout << "What is your first name? ";
cin >> buffer;

// replace their first name with string in buffer
replace(employee_tag, DEFAULT_NAME_FIRST, buffer);
// then clear the buffer
buffer.clear();

// adk the employee for their last name
cout << "What is your last name? ";
cin >> buffer;
cout << endl;

// replace their last name with string in buffer
replace(employee_tag, DEFAULT_NAME_LAST, buffer);
// then clear the buffer
buffer.clear();

// thank them and display their name tag:
cout << "Thank You!" << endl;
cout << "Here is your name tag: " << endl;
cout << employee_tag;

exit(EXIT_SUCCESS);
}

/* Will find and replace the given sub-string within
* the user provided string with the new sub-string.
*
* Require: user_string contains sub_string
* Ensure: user_string !contains sub_string &&
* user_string contains new_sub_string
*/
void replace(string& user_string,
const string& sub_string,
const string& new_sub_string) {

// find position of sub_string in user_string

// replace sub_string in user_string with new_sub_string
}
What was wrong with your existing thread?
http://www.cplusplus.com/forum/beginner/112289/
this is a homework assignment using replacement strings. When the code is ran BEFORE making corrections, it will ask for first and last name. The OUTPUT after the user makes in the input, the program will always out as DEFAULT FIRST NAME AND ETC.

I have to use the replace string to over ride that DEFAULT so in the end, it will show up what the user put in for first and last name.
Topic archived. No new replies allowed.