====== C++ Crashkurs / Übung 1 ====== C-Funktionen versus C++ globale Funktionen, Klassen-Funktionen und statische Klassen-Funktionen. **Ueb1.h:** // File : Ueb1.h // #include "..\stdafx.h" #include "Ueb1.NameMangling.h" int _ueb (int argc, _TCHAR* argv[]) { CFoo f; Foo(); // C-Funktion Bah(); // Globale Funktion CFoo::Foo(); // Statische Funktion einer Klasse f.Bah(); // Methode einer Instanz return 0; } // EOF **Ueb1.NameMangling.h:** // File : Ueb1.NameMangling.h // #include "Ueb1.PrintFunctionInfo.h" extern "C" { void Foo () { PRINT_INFO("C-function Foo()"); } } void Bah () { PRINT_INFO("Global function Bah()"); } class CFoo { public: static void Foo () { PRINT_INFO("Static member function CFoo::Foo()"); } void Bah () { PRINT_INFO("Member function CFoo::Bah()"); } }; // EOF **Ueb1.PrintFunctionInfo.h:** // File : Ueb1.PrintFunctionInfo.h // #include "..\stdafx.h" #define PRINT_INFO(header) PrintInfo(__FUNCTION__, __FUNCDNAME__, __FUNCSIG__, header) void PrintInfo (const char* FUNCTION, const char* FUNCDNAME, const char* FUNCSIG, const char* pszHeader) { std::cout << std::endl << "Info: " << pszHeader << std::endl << " Function name : " << FUNCTION << std::endl << " Decorated function name: " << FUNCDNAME << std::endl << " Function signature : " << FUNCSIG << std::endl; } // EOF **Programm.cpp:** - Der Einstiegspunkt // Programm.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Ueb1.h" int _tmain (int argc, _TCHAR* argv[]) { return _ueb(argc, argv); } // EOF **stdafx.h:** // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #include #include // TODO: reference additional headers your program requires here #include #include // EOF **targetver.h:** // Including SDKDDKVer.h defines the highest available Windows platform. // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. #pragma once #include ---- Stand: 19.09.2014 --- //[[feedback.jk-wiki@kreick.de|: Jürgen Kreick]]// EOF