this is the program to remove vowel from the string. i am having problem in this code. It's not giving any error. and not working. can any1 help me with this code that what i am doing wrong in this?
#include <iostream>
using namespace std;
class mcchauhan{
public:
void enterTheString(string z){
x=z;
}
protected:
string x;
};
class vowel:public mcchauhan{
public:
string vowelFind(){
string finalString;
The reason it is not working correctly is because you are handling inheritance the wrong way. Even though mcchauhan is able to use vowels functions/protected variables that doesn't mean that the values from the class objects are shared between them.
In this case you create a mcchauhan class object called bo and pass a string into it. You then ask an mo object to work with that string even though for that particular object it has never been told what the string is.
You will want to use just 1 class object (In this case the vowel) and run all of the functions through that, it will still be able to access the string from the mcchauhan etc.
James2250:
thanks James2250. Yes its working now. but there is a problem if i am running this program, output is showing an extra reverse ? at the end. Can you throw some light on this? Output is like that "mynk chhn? "
#include <iostream>
using namespace std;
class mcchauhan{
public:
protected:
string x;
};
class vowel:public mcchauhan{
public:
string vowelFind(string x){
string finalString;
it's a garbage value which generally occur due to memory leaks or improper memory assignment. You can see link that i posted and may you get some idea for loop.