Buscar este blog

lunes, 16 de abril de 2012

Dia 16/04

Librerias C++

#include -->Internas --> El propio lenguakje
             -->Externas--> Del usuario

1º//Cabeceras (.h,.hpp) -->Definición de datos globales y cabeceras
2º// Código (.C,.cpp) --> Implementación

EJEMPLO:

main.cpp

#include <cstdlib>
#include <iostream>
#include "libreria.h"

using namespace std;
//DECLARACION DE FUNCIONES Y PROCEDIMIENTOS



int main(int argc, char *argv[])
{
    int a,b;
    printf("Escribe un numero: ");
    scanf("%d",&a);
    printf("Escribe un numero: ");
    scanf("%d",&b);
    printf("El resultado es:   %d\n",suma(a,b));
    system("PAUSE");
    return EXIT_SUCCESS;
}

libreria.h

int suma(int a,int b);

 libreria.cpp

//FUNCIION QUE SUMA 2 NUMEROS
//RECIBE DOS NUMEROS DE ENTRAA Y DEVUELVE UN NUMERO ENTERO
//QUE ES LA SUMA DE LOS PARAMETROS DE ENTRADA

int suma(int a,int b)
{
    int c;
    c=a+b;
    return c;
}

//FIN DE LA FUNCION SUMA



Alberto





No hay comentarios:

Publicar un comentario