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
Zitat von »"main.cpp"«
#pragma once
#include "classA.cpp"
#include "classB.cpp"
int main(int argc, char** args)
{
A a;
B b;
a.b = &b;
b.a = &a;
return 0;
}
Zitat von »"classA.cpp"«
#pragma once
#include "classB.cpp"
class A
{
public:
B* b; // Fehler, Klasse B ist nicht bekannt
};
Zitat von »"classB.cpp"«
#pragma once
#include "classA.cpp"
class B
{
public:
A* a; // Fehler, Klasse A ist nicht bekannt
};
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
#pragma once class B; class A { public: B* b; }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
#pragma once class A; class B { public: A* a; }; |
C-/C++-Quelltext |
|
1 2 3 4 |
#include "classA.h" #include "classB.h" // definition |
C-/C++-Quelltext |
|
1 2 3 4 |
#include "classB.h" #include "classA.h" // definition |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 |
#include "classA.h" #include "classB.h" int main() { A a; B b; a.b = &b; b.a = &a; } |
Quellcode |
|
1 2 3 4 |
#ifndef _CLASS_H_ #define _CLASS_H_ #endif |
Zitat von »"TrikkieMikkie"«
Das wär mir neu dot. Ich verwende auch das von knivil genannte Schema.
Noch nie Probleme damit...
Zitat von »"ISO/IEC 14882:2003(E) 17.4.3.1.2 [lib.global.names«
Global names"]
-1- Certain sets of names and function signatures are always reserved to the implementation:
* Each name that contains a double underscore ("__") or begins with an underscore followed by an uppercase letter (lex.key) is reserved to the implementation for any use.
* Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.*
[Footnote: Such names are also reserved in namespace ::std (lib.reserved.names). --- end foonote]
Zitat von »"chriss"«
Wenn man viel mit C# und Java arbeitet muss man echt aufpassen das man nicht die Basics von C++ vergisst
C-/C++-Quelltext |
|
1 2 3 4 |
class A { void func(); }; |
C-/C++-Quelltext |
|
1 2 3 4 |
class A { virtual void func()=0; }; |
C-/C++-Quelltext |
|
1 2 3 |
class A; void A::func(); |
Werbeanzeige