-
subclass
Code:
#ifndef __cDATE_H
#define __cDATE_H
#include <iostream.h>
#include <string.h>
class cSTRING
{
protected:
int _nCmpValue, _num1, _num2;
char *pszName1, *pszName2;
public:
cSTRING();
cSTRING(char *pname, int returnVal);
cSTRING(char *pszStr1);
cSTRING(cSTRING &rhs);
~cSTRING();
char *getName1()
{
return this->pszName1;
}
char *getName2()
{
return this->pszName2;
}
void print()
{
cout << pszName1 << endl;
}
cSTRING& operator=(const cSTRING& cStr);
cSTRING operator+(const cSTRING& cStr);
cSTRING& operator+=(const cSTRING& cStr);
int operator==(const cSTRING& cStr);
int operator!=(const cSTRING& cStr);
cSTRING& Reverse();
friend ostream &operator<<(ostream &os, cSTRING& cStr);
friend istream &operator>>(istream& is, cSTRING& cStr);
int palindrome(const cSTRING& cStr);
};
class cFILENAME:public cSTRING
{
protected:
char *pszFName1;
char *pszFName2;
public:
cFILENAME();
cFILENAME(char *pszStr1);
cFILENAME(cFILENAME &rhs);
~cFILENAME();
//cFILENAME(cSTRING& s):cSTRING(s){}
const char* getExtension() const;
cFILENAME& toUpper();
cFILENAME& toLower();
char *getFName1()
{
return this->pszFName1;
}
char *getFName2()
{
return this->pszFName2;
}
};
#endif
i havent done this before, but how would i make a CSTRING of a filename? i am looking @ about.com tutorial, but is very confusing.
-
>class cFILENAME:public cSTRING
What good is inheritance here? Containment would be much better as you don't use anything that requires internal knowledge of cSTRING, and a filename is only represented by a string, it isn't a string in and of itself logically:
Code:
class cFILENAME
{
cSTRING FName;
public:
cFILENAME();
cFILENAME(char *pszStr1)
: FName(pszStr1)
{}
cFILENAME(cSTRING &rhs)
: FName(rhs)
{}
// No destructor needed
const char* getExtension() const;
cFILENAME& toUpper();
cFILENAME& toLower();
char *getFName1()
{
return FName.getName1();
}
char *getFName2()
{
return FName.getName2();
}
};
-
lol dont tell me tell te stupid teachers :D :D :D
-
>lol dont tell me tell te stupid teachers
The next time you see your teachers, give them a good hard slap and say it's from Julienne Guth. ;)