where am I going wrong?

Create a class called strMetric that will give information about a string. You should provide a default constructor and
an overloaded constructor that takes a string as an argument.
Your string metric class should have the following functioality

* A method called length that returns the length of the string
* A method called countVowels that returns the number of vowels in a string
* A method called Upper that returns the number of upper case characters
* A method called Lower that returns the number of lower case characters
* A method called sumChars that returns the sum of all characters within the string

For this assignment I want you to use the strMetric class as the derived class and use the string class as the base class.

To assign the string to the base class you are probably going to want to use the assign method from class string
*/

//Header file

#ifndef STRMETRIC
#define STRMETRIC
#include <iostream>
using namespace std;
#include <string>

class strMetric:public string
{
private:
string str;
public:
strMetric ();
strMetric (string s);
int length();
int countVowels();
int upper();
int lower();
int sumChars();

};
#endif

//cpp file

#include"strMetric.h"

strMetric::strMetric()
{
this("0");
}
strMetric::strMetric (string s)
{
string(s);
}
int strMetric::length()
{
return this->length();

}
int strMetric::countVowels()
{
string::iterator p;
char vowels=0;
for(p = 0; str.begin()<str.length();p++)
{
switch(p(toupper))
{
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
}
count++
}
return vowels;
}
int strMetric::upper()
{
string::iterator p;
char count=0;
for(p = 0; str.begin()< str.length(); p++)
{
if(p == (toupper))
count = p;
count++
}
return count;

}
int strMetric::lower()
{
string::iterator p
char count =0;

for(p =0; str.begin() < str.length(); p++)
{
if(p == (tolower))
count = p;
count++
}
return count;

}
int strMetric::sumChars()
{
string::iterator p;
char sum = 0;
for(p = 0; str.begin()<str.length();p++)
{
if(p == char)
sum = p
}
return sum;
}
[code][/code] tags.

Also, what is the problem?
Last edited on
Topic archived. No new replies allowed.