Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 02-06-2015
giulichajari giulichajari is offline
Miembro
 
Registrado: nov 2012
Posts: 306
Poder: 12
giulichajari Va por buen camino
Obtener fecha mas una cantidad dias

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:

Código PHP:
#include <time.h>
#define damefecha

    
struct tmdamefecha(struct tmvalor){

         
valor->tm_mday += 30;

         return(
valor);
}; 
y en el main:

Código PHP:
#include <iostream>
#include <time.h>
#include <vector>
#include "fecha.h" 
y obtengo fecha.h expected unqualified-id before "struct"

este es todo el programa:

Código PHP:
#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 NombreAstring NacionalidadAtime_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 editorialLint 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 identificadorCstring estadoC,Libro L1C){
                           
identificador=identificadorC;
                           
estado=estadoC;  
                         
                           };
            
string getEstado(){
                
                   return (
estado);
                 
                   };
            
void setEstado(string nuevoEstado){
                 
estado=nuevoEstado;
                 
                 };
                 
      };
class 
Prestamo{
      private:
              
struct tmfechaPrestamo;
              
struct tmfechaDevolucion;
             
      public:
                        
             
Prestamo::Prestamo(struct tmfechaPrestamoP){
                                       
fechaPrestamo=fechaPrestamoP;
                                       
             };
             
struct tmgetfechaPrestamo(){return (fechaPrestamo);};
           
struct tmgetFechaDevolucion(){return  (fechaDevolucion);};
      
void setfechaDevolucion(struct tmfechanueva){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 tmfechaDevolucion=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;

}; 

Última edición por nlsgarcia fecha: 02-06-2015 a las 16:50:03. Razón: Sintaxis C++
Responder Con Cita
  #2  
Antiguo 02-06-2015
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Por no variar la definición de tu función damefecha, mira este código:

Código PHP:
struct tmDameFecha(struct tmtime)
{
  
time_t t mktime(time);
  
+= 30*24*60*60;
  return 
localtime(&t);

time_t es un entero que representa la fecha en segundos transcurridos desde las 00:00 horas del 1 de enero de 1970, son segundos, de manera que debes sumar 30 días pasados a segundos.


Saludos.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Calcular fecha Fin dada fecha inicio y dias, meses o años transcurridos fide_uci HTML, Javascript y otros 1 15-11-2011 19:52:40
Cantidad de Dias jocey Varios 3 22-10-2007 22:25:04
Sumatoria por Cantidad de Días vencidos jandres Varios 0 08-02-2007 20:02:46
Obtener cantidad de Dias en determ Mes Por fa kamux1 Varios 3 18-01-2007 22:38:45
cuando a una fecha le resto una cantidad de dias,no se en que formato enviar el param federiconqn21 Firebird e Interbase 1 10-04-2006 16:32:37


La franja horaria es GMT +2. Ahora son las 15:31:17.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi