Ok I did it for you, took me a long time, hope it was worth it!
Code:
#include <iostream>
#include <string>
#include <list>
using namespace std;
class Convert
{
private:
string input;
list<string> listSplit;
list<int> listInteger;
list<string> listString;
list<float> listFloat;
public:
Convert(string inputString)
{
input = inputString;
}
void performCheck()
{
createSplitArray();
checkType();
createResult();
}
void createSplitArray()
{
string s=input+" ", getString;
while (s!="")
{
listSplit.push_back(s.substr(0,s.find(" ")));
s.erase(0,s.find(" ")+1);
}
}
int checkNumber(char test)
{
int x = int(test);
if (x<58 && x>47 || x==46)
return 1;
return 0;
}
void checkType()
{
string x;
char y;
int checklen(0), len(0);
list<string>::iterator i;
for (i=listSplit.begin() ; i!=listSplit.end() ; i++)
{
x = *i;
checklen = 0;
len = x.length();
string::iterator j;
for (j=x.begin() ; j<x.end() ; j++)
{
y = *j;
if(checkNumber(y)==0)
{
listString.push_back(x);
break;
}
else
{
checklen++;
}
}
if(checklen==len && x.find(".")==string::npos)
{
listInteger.push_back(atoi(x.c_str()));
}
else if(checklen==len && x.find(".")!=string::npos)
{
listFloat.push_back(atof(x.c_str()));
}
}
}
void createResult()
{
list<string>::iterator i;
list<int>::iterator j;
list<float>::iterator k;
cout<<"Strings are: ";
for (i=listString.begin() ; i!=listString.end() ; i++)
cout<<*i<<" ";
cout<<endl;
cout<<"Integers are: ";
for (j=listInteger.begin() ; j!=listInteger.end() ; j++)
cout<<*j<<" ";
cout<<endl;
cout<<"Floats are: ";
for (k=listFloat.begin() ; k!=listFloat.end() ; k++)
cout<<*k<<" ";
cout<<endl;
}
};
int main()
{
Convert a("X YZ 55 58.6 32j 44.k");
a.performCheck();
return 0;
}
Output:
Code:
Strings are: X YZ 32j 44.k
Integers are: 55
Floats are: 58.6
For the input: X YZ 55 58.6 32j 44.k
And you have those content in the lists of the classes as well.
PS.0: Was a learning experience for me. Never coded > 100 lines in C++ until today. I've been a fan of C and Python alone and shall continue to be so, even after this.
PS.1: I'll leave the characters part and minor fixes to you.