Zum Hauptinhalt springen

C++ - Static Library

 1// Literatur: Vorlesungsunterlagen ISE3 (FH-Hagenberg)
 2
 3/*********************************************************************/
 4/* Projekt fuer statische Library (erzeugt StaticLib.lib)            */
 5/*********************************************************************/
 6
 7// StaticLib.h:
 8//---------------------------------------------------------------------
 9    #ifndef STATICLIB_H
10    #define STATICLIB_H
11
12    int Add(int const val1, int const val2);
13
14    #endif
15
16
17// StaticLib.cpp:
18//---------------------------------------------------------------------
19    #include "StaticLib.h"
20
21    int Add(int const val1, int const val2)
22    {
23        return val1 + val2;
24    }
25
26
27
28/*********************************************************************/
29/* Projekt welches die Library verwendet                             */
30/*  die Library wird bei den Abhaengigkeiten des Linkers eingetragen */
31/*********************************************************************/
32
33// TestStaticLib.cpp:
34//---------------------------------------------------------------------
35    #include <iostream>
36    #include <conio.h>
37    #include "StaticLib.h"
38
39    using namespace std;
40
41    int main()
42    {
43        int sum = Add(1,2);
44        cout << "Summe: " << sum << endl;
45
46        _getch();
47        return 0;
48    }