Write a program to create a class Name with data member as char array. Write a member
function to erase a particular character from the given input C++ string.
#include<iostream>
using namespace std;
class Name{
private:
char first_name[10];
public:
void erase_character(char h);
};
void Name::erase_character(char h){
char first_name [10] = "starter";
{
for(int i=0; i<10;i++){
if(h==first_name[i]){
first_name[i] = 0;
}
else{
cout<<first_name[i];
}
}
}
}
int main(){
Name n;
n.erase_character('a');
}
Comments
Leave a comment