Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
- class A {
- private:
- char *str;
- short len;
- public:
- A(short m, string source);
- virtual char func(short i = 0);
- short getLen();
- friend ostream& operator<<(ostream &output, A);
- protected:
- char get(short i);
- };
- class B : public A {
- private:
- short p;
- public:
- B(short m, string source);
- char func(short i);
- };
- class C : public A {
- private:
- char x;
- public:
- C(short n, string source, char y);
- char func(short i);
- string g(char c);
- };
- int main() {
- srand(111222333);
- A *vett[50];
- string S="supercalifragilistichespiralidoso";
- for(int i=0; i<50; i++){
- short n=3+rand()%10;
- if(rand()%2==0)
- vett[i]= new B(n, S);
- else
- vett[i]= new C(n, S, (char) (rand()%('z'-'a'+1)+'a'));
- }
- ostream &operator<<(&C, B);
- cout << vett;
- }
- A::A(short q, string sorgente) {
- sorgente = str;
- q = len;
- }
- char A::get(short i) {
- return str[i%len];
- }
- short A::getLen() {
- int m;
- m = len;
- return m;
- }
- B::B(short w, string sorgente) : A() {
- int numVocali=0;
- for (int i=0; i<sorgente.length(); i++) {
- if (sorgente[i] == 'a' || sorgente[i]=='e' || sorgente[i]=='i' || sorgente[i]=='o' || sorgente[i]=='u')
- numVocali++;
- }
- short p=1+numVocali;
- }
- char B::func(short i) {
- string sorgente;
- for (int j=i; j<sorgente.length(); j++) {
- if (sorgente[j]!='a' || sorgente[j]!='e' || sorgente[j]!='i' || sorgente[j]!='o' || sorgente[j]!='u')
- return sorgente[j];
- else
- return char ('X');
- }
- }
- C::C(short n, string sorgente, char y) : A() {
- }
- char C::func(short i) {
- string sorgente;
- for (int k = i; k<sorgente.length(); k++) {
- if (sorgente[k]>x)
- return sorgente[i];
- else
- return x;
- }
- }
- string C::g(char c) {
- string sorgente;
- string s2= x + sorgente + c;
- return s2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement