1 / 7

Ejemplo C++

Ejemplo C++ . Clase sencilla. class Persona { private: char ColorCabello[20] public: int Altura; int Edad; private: void Pasear(); public: void Charlar(); void PintarCabello(); };. Funciones inline. class InfoFecha { int Mes, Dia, Anyo; public:

seth
Download Presentation

Ejemplo C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ejemplo C++

  2. Clase sencilla class Persona { private: char ColorCabello[20] public: int Altura; int Edad; private: void Pasear(); public: void Charlar(); void PintarCabello(); };

  3. Funciones inline class InfoFecha { int Mes, Dia, Anyo; public: void FijarFecha(int NumMes, int NumDia, NumAnyo) { Mes = NumMes; Dia = NumDia; Anyo = NumAnyo; } void LeerFecha(int &NumMes, int &NumDia, int &NumAnyo); }; void InfoFecha:: LeerFecha(int &NumMes, int &NumDia, int &NumAnyo) { Mes = NumMes; Dia = NumDia; Anyo = NumAnyo; }

  4. Constructores y destructores class Complejo { public: Complejo(); Complejo(Complejo& c); Complejo(double ParteReal, double ParteImag); ▬Complejo(); protected: double real; double imag; }; Complejo t1; Complejo t2(4.5,7.5); ….

  5. Funciones Amigas class Perro { private char Nombrep[30]; public: … void friend maestro(const Perro &p, const Gato &g); … }; class Gato { private char Nombreg[30]; public: … void friend maestro(const Perro &p, const Gato &g); … }; … void maestro(consPerro &p, const Gato &g) { if (!strcmp(p.Nombrep,g.Nombreg)); cout <<“Perros y gatos no tienen los mismos maestros”; }

  6. Herencia class Caja { public: int Anchura, Peso; void LeerPeso(int p); void LeerAnchura(int a); }; class CajaColor : public Caja { public: int color; void LeerColor(int c); };

  7. Herencia Múltiple class Circulo { float radio; public: Circulo(float r) {radio = r;} float Area() {return radio*radio*3.1415;} }; class Mesa { float altura; public: Mesa(float h) {altura = h;} float Altura() {return altura;} } class MesaRedonda : public Mesa, public Circulo { int color; public: MesaRedonda(float h, float r, int c); int Color() {return color;} };

More Related