giulichajari
02-06-2015, 16:15:53
Necesito sumarle 30 dias a la fecha prestamo para obtener la fechadevolucion en un sistema bibliotecario.
(lo hago por consola)
Primero hice un fichero .h fecha.h:
#include <time.h>
#define damefecha
struct tm* damefecha(struct tm* valor){
valor->tm_mday += 30;
return(valor);
};
y en el main:
#include <iostream>
#include <time.h>
#include <vector>
#include "fecha.h"
y obtengo fecha.h expected unqualified-id before "struct"
este es todo el programa:
#include <iostream>
#include <time.h>
#include <vector>
#include "fecha.h"
using namespace std;
class Autor{
private:
string Nombre;
string Nacionalidad;
time_t fechaNac;
public:
Autor(string NombreA, string NacionalidadA, time_t fechaNacA){
Nombre=NombreA;
Nacionalidad=NacionalidadA;
fechaNac=fechaNacA;
};
};
class Libro{
private:
string titulo;
string editorial;
int ano;
Autor *autor;
public:
Libro::Libro(string tituloL,string editorialL, int anoL,string tipoL){
titulo=tituloL;
editorial=editorialL;
ano=anoL;
};
void setAutor(Autor *A1){
this->autor=A1;
};
};
class Copia{
private:
int identificador;
string estado;
Libro *L1;
public:
int x;
Copia::Copia(int identificadorC, string estadoC,Libro L1C){
identificador=identificadorC;
estado=estadoC;
};
string getEstado(){
return (estado);
};
void setEstado(string nuevoEstado){
estado=nuevoEstado;
};
};
class Prestamo{
private:
struct tm* fechaPrestamo;
struct tm* fechaDevolucion;
public:
Prestamo::Prestamo(struct tm* fechaPrestamoP){
fechaPrestamo=fechaPrestamoP;
};
struct tm* getfechaPrestamo(){return (fechaPrestamo);};
struct tm* getFechaDevolucion(){return (fechaDevolucion);};
void setfechaDevolucion(struct tm* fechanueva){fechaDevolucion=fechanueva;};
};
class Lector{
private:
string nombre;
int prestamos;
public:
Prestamo *P1;
Lector::Lector(string nombreL,int prestamosL){
nombre=nombreL;
prestamos=prestamosL;
};
void setprestamos(int a){
prestamos=prestamos + a;
};
void solicitarPrestamo(Copia *C1){
if (C1->getEstado()=="biblioteca"){
if (this->prestamos<3) {
P1 = new Prestamo(29/05/15);
C1->setEstado("prestado");
cout<<(P1->getFechaDevolucion());
setprestamos(1);
}
else{
cout<<"llego al limite"<<endl;
};
}else{
cout<<"libro no disponible"<<endl;
};
};
};
//string estados[4]={"prestado","biblioteca","retraso","reparacion"};
//string tipos[4]={};
int main(){
int a;
Libro *L1=new Libro("Martin Fierro","Columba",1835,"poesia");
Libro *L2=new Libro("El quijote","Española",1500,"novela");
Autor *A1=new Autor("jose","hernandez",12-4-1825);
Autor *A2=new Autor("Cervantes","Saavedra",11-8-1499);
L1->setAutor(A1);
Copia *C1=new Copia(1,"biblioteca",*L1);
Copia *C2=new Copia(2,"prestado",*L2);
Lector *Lector1=new Lector("Giuli",2);
Prestamo *P1=new Prestamo(12/12/12);
struct tm* fechaDevolucion=damefecha(P1->getfechaPrestamo);
cout<<("libros en biblioteca: 1- Martin Fierro 2 -El quijote")<<endl;
cout<<("3-salir")<<endl;
cin>>a;
do{
switch (a)
case 1:
Lector1->solicitarPrestamo(C1);
break;
}while (a!=3);
system("pause");
return 0;
};
(lo hago por consola)
Primero hice un fichero .h fecha.h:
#include <time.h>
#define damefecha
struct tm* damefecha(struct tm* valor){
valor->tm_mday += 30;
return(valor);
};
y en el main:
#include <iostream>
#include <time.h>
#include <vector>
#include "fecha.h"
y obtengo fecha.h expected unqualified-id before "struct"
este es todo el programa:
#include <iostream>
#include <time.h>
#include <vector>
#include "fecha.h"
using namespace std;
class Autor{
private:
string Nombre;
string Nacionalidad;
time_t fechaNac;
public:
Autor(string NombreA, string NacionalidadA, time_t fechaNacA){
Nombre=NombreA;
Nacionalidad=NacionalidadA;
fechaNac=fechaNacA;
};
};
class Libro{
private:
string titulo;
string editorial;
int ano;
Autor *autor;
public:
Libro::Libro(string tituloL,string editorialL, int anoL,string tipoL){
titulo=tituloL;
editorial=editorialL;
ano=anoL;
};
void setAutor(Autor *A1){
this->autor=A1;
};
};
class Copia{
private:
int identificador;
string estado;
Libro *L1;
public:
int x;
Copia::Copia(int identificadorC, string estadoC,Libro L1C){
identificador=identificadorC;
estado=estadoC;
};
string getEstado(){
return (estado);
};
void setEstado(string nuevoEstado){
estado=nuevoEstado;
};
};
class Prestamo{
private:
struct tm* fechaPrestamo;
struct tm* fechaDevolucion;
public:
Prestamo::Prestamo(struct tm* fechaPrestamoP){
fechaPrestamo=fechaPrestamoP;
};
struct tm* getfechaPrestamo(){return (fechaPrestamo);};
struct tm* getFechaDevolucion(){return (fechaDevolucion);};
void setfechaDevolucion(struct tm* fechanueva){fechaDevolucion=fechanueva;};
};
class Lector{
private:
string nombre;
int prestamos;
public:
Prestamo *P1;
Lector::Lector(string nombreL,int prestamosL){
nombre=nombreL;
prestamos=prestamosL;
};
void setprestamos(int a){
prestamos=prestamos + a;
};
void solicitarPrestamo(Copia *C1){
if (C1->getEstado()=="biblioteca"){
if (this->prestamos<3) {
P1 = new Prestamo(29/05/15);
C1->setEstado("prestado");
cout<<(P1->getFechaDevolucion());
setprestamos(1);
}
else{
cout<<"llego al limite"<<endl;
};
}else{
cout<<"libro no disponible"<<endl;
};
};
};
//string estados[4]={"prestado","biblioteca","retraso","reparacion"};
//string tipos[4]={};
int main(){
int a;
Libro *L1=new Libro("Martin Fierro","Columba",1835,"poesia");
Libro *L2=new Libro("El quijote","Española",1500,"novela");
Autor *A1=new Autor("jose","hernandez",12-4-1825);
Autor *A2=new Autor("Cervantes","Saavedra",11-8-1499);
L1->setAutor(A1);
Copia *C1=new Copia(1,"biblioteca",*L1);
Copia *C2=new Copia(2,"prestado",*L2);
Lector *Lector1=new Lector("Giuli",2);
Prestamo *P1=new Prestamo(12/12/12);
struct tm* fechaDevolucion=damefecha(P1->getfechaPrestamo);
cout<<("libros en biblioteca: 1- Martin Fierro 2 -El quijote")<<endl;
cout<<("3-salir")<<endl;
cin>>a;
do{
switch (a)
case 1:
Lector1->solicitarPrestamo(C1);
break;
}while (a!=3);
system("pause");
return 0;
};