I've written a C++ program that compiles successfully but is give me some logic error. It's giving me some negative numbers can someone please run the code and see what ive done wrong.
Built with Visual Studio 2008
#include"stdafx.h"
#include<string>
#include<iostream>
using namespace std;
class vowels
{
public:
vowels();void getdata();void processdata();void display();string input;
private:
int a;int e;int i; int o; int u; int y;
};
vowels::vowels ()
{
int a=0; int e=0; int i=0; int o=0; int u=0; int y=0;input="";
}
void vowels::getdata()
{
cout<<"Enter String of Characters->>";
getline(cin,input);
}
void vowels::processdata()
{
if(input=="A" && input=="a")
{
a=a++;
}
else if(input=="E" && input=="e")
{
e=e++;
}
else if(input=="I" && input=="i")
{
i=i++;
}
else if(input=="O" && input=="o")
{
o=o++;
}
else if(input=="U" && input=="u")
{
u=u++;
}
}
void vowels::display()
{
printf("Vowels present in the typed string are:\n");
cout<<"A="<<a<<endl;
cout<<"E="<<e<<endl;
cout<<"I="<<i<<endl;
cout<<"O="<<o<<endl;
cout<<"U="<<u<<endl;
}
int main()
{
vowels countvowels;
countvowels.getdata();
countvowels.processdata();
countvowels.display();
system("pause");
}