Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
PD
unregistriert
C-/C++-Quelltext |
|
1 |
template<class a, class b> void weissnicht(); |
Zitat von »"Microsoft"«
type_info Class
C++ Specific —>
The type_info class describes type information generated within the program by the compiler. Objects of this class effectively store a pointer to a name for the type and an encoded value suitable for comparing two types for equality or collating order. The encoding rules and collating sequence for types are unspecified and may differ between programs.
class type_info {
public:
virtual ~type_info();
int operator==(const type_info& rhs) const;
int operator!=(const type_info& rhs) const;
int before(const type_info& rhs) const;
const char* name() const;
const char* raw_name() const;
private:
...
};
Note You must include the typeinfo.h header file in order to use the type_info class.
END C++ Specific
PD
unregistriert
C-/C++-Quelltext |
|
1 |
template<class T> inline T* Get() { ... } |
C-/C++-Quelltext |
|
1 |
cObjm.Get<CGrafik>()->update(); |
Zitat
c:\dokumente und einstellungen\pq\desktop\programmieren\the labyrinth\mainclass.cpp(52) : error C2275: "CGrafik" : Ungültige Verwendung dieses Typs als Ausdruck
c:\dokumente und einstellungen\pq\desktop\programmieren\the labyrinth\grafik.h(19) : Siehe Deklaration von 'CGrafik'
c:\dokumente und einstellungen\pq\desktop\programmieren\the labyrinth\mainclass.cpp(52) : error C2059: Syntaxfehler : ')'
PD
unregistriert
Zitat
Mich würde mal intressieren ob man 2 Variablen auf den gleichen Datentyp überprüfen kann. Ein beispiel, ich habe folgende Template Funktion:
Code (C++):
template<class a, class b> void weissnicht();
Kann ich nun irgendwie überprüfen ob a und b vom selben typ sind? Gibt es da eine möglichkeit?
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
template<typename T, typename U> struct AreSame { enum {value = false}; }; template<typename T> struct AreSame<T, T> { enum {value = true}; }; |
PD
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include <iostream> class a { private: int r; public: template<class T> T Get() { return static_cast<T>(r); } }; int main() { a b; std::cout << (b.Get<int>()) << std::endl; return 0; } |
Zitat
C:\Dokumente und Einstellungen\PQ\Desktop\Programmieren\test\main.cpp(14) : error C2062: 'int'-Typ unerwartet
PD
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
template <bool, typename T, typename U> struct Select { typedef T; }; template <typename T, typename U> struct Select<false, T, U> { typedef U; }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
template <typname T> struct SimplesTemplate { typedef T Type; }; template <typaname T> struct AnderesTemplate { typedef typename SimplesTemplate<T>::Type Type; }; |
PD
unregistriert
Werbeanzeige