[c++] Dziedziczenie iteratora
Ostatnio zmodyfikowano 2014-12-05 08:04
anek155 Temat założony przez niniejszego użytkownika |
[c++] Dziedziczenie iteratora » 2014-12-04 23:49:28 Witam! Mam problem z dziedziczeniem po iteratorze, tzn chcę aby: #include "Ite.h" #include "Sre.h" #include <iostream>
Sre::Sre( Ite * x ) : Ite( * x ) { a = 0; su = 0; this->wite = x; } Sre::~Sre() { } void Sre::next() { this->wite += 1; } void Sre::back() { this->wite -= 1; }
void Sre::update() { ++a; su +=( float ) * wite; } float Sre::sred() { cout << " a=" << a << endl; return su / a; }
Działało jak: #include "Ite.h" #include "Fra.h" #include <iostream> using namespace std; Ite::Ite( Fra * x ) { n = 0; sum = 0; this->wfra = x; } Ite::~Ite() { } void Ite::next() { this->wfra += 1; } void Ite::back() { this->wfra -= 1; } Fra * Ite::ret() { return wfra; } void Ite::update() { ++n; sum +=( float ) * wfra; }
Sam iterator Ite działa poprawnie wraz z Fra i mainem. Log kompilacji (błędy): Sre.cpp: In member function `void Sre::update()': Sre.cpp:30: error: `class Ite' used where a floating point value was expected Sre.cpp:30: error: aggregate value used where a float was expected
make.exe: *** [Sre.o] Error 1
Wykonanie zakończone
|
|
darko202 |
» 2014-12-05 08:04:00 |
|
« 1 » |