Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Given two strings like x=?hello? and y=?open?, remove any
character from string x which is also used in string y,
thus making the result x=?hll?.

Answer Posted / newpolaris

bool IsInStr(char ch, const std::string& B)
{
return std::string::npos != B.find(ch);
}

// act fuction
std::string remove_same_char(const std::string& A, const
std::string& B)
{
typedef std::string::const_iterator cstr_const_it;
cstr_const_it iCSTR = A.begin();

// FOR OPTIMIZATION NRVO IS NEEDED
// ? IS POSSIBLE?
std::string _rt;

while ( iCSTR != A.end() )
{
if (!IsInStr(*iCSTR,B)) _rt+=*iCSTR;

iCSTR++;
}

return _rt;
}

int main()
{
std::string x = "hello";
const std::string y = "open";
x = remove_same_char(x, y);
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is encapsulation in oop?

1044


why reinterpret cast is considered dangerous?

2387


What is a class in oop?

1124


What are two types of polymorphism?

1070


Give two or more real cenario of virtual function and vertual object

2327


Templates mean

2075


What is class and object in oops?

1138


Why is polymorphism used?

1035


Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box

2611


INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

2202


Get me an image implementation program.

1978


Plese get me a perfect C++ program for railway/airway reservation with all details.

3896


What is the highest level of cohesion?

1042


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

2317


What is constructor overloading in oop?

1132