|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Junior Member
Iscritto dal: Feb 2007
Messaggi: 5
|
C++ - Diventerò matto?
Ragazzi, mi potreste dare una mano o indirizzarmi, poi vado solo...altrimenti non ne vengo fuori?
Debbo realizzare un progetto in c++ che ho già sviluppato in java...qlcs tipo modellare Espressioni numeriche tramite oggetti... Posto la classe astratta e la prima classe che la estende/implementa.. Uso Visual C++ 2008 Express Codice:
********** Esp.cpp ____________ #include <string> #include <sstream> class Esp{ public: virtual Esp semplifica()=0; virtual Esp deriva()=0; virtual Esp toString()=0; int main() { Esp e ; e = new EspCost(5); e.semplifica; e.deriva; e.toString; } } ******* EspCost.cpp ____________ #include <string> #include <sstream> #include "EspCost.h" #include <string> #include <sstream> EspCost(int valore){ this.valore = valore; } int getValore(){ return valore; } void setValore(int valore){ this.valore = valore; } Esp semplifica(){ return this; } Esp deriva(string s){ valore = 0; } string toString(){ ostringstream oss; oss << valore; string res = oss.str(); return res; } ********************** EspCost.h ___________________ using namespace std; class EspCost : public Esp{ private: int valore; public: EspCost(int valore); int getValore(); void setValore(int valore); Esp semplifica(); Esp deriva(string s); string toString(); } ______________________ ![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Oct 2001
Messaggi: 11471
|
|
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 15:03.