I'm have not forward intentionally.
My question are 'why the project can be build and have no errors' ?
I have not tools in my QT+mingw to check it?
Thanks
I'm have not forward intentionally.
My question are 'why the project can be build and have no errors' ?
I have not tools in my QT+mingw to check it?
Thanks
I meant that forward declaring is somethig that can help you when you want to have class A using class B and the other way around.
How did you include the headers ? If you did somethig like:
then think about it, in order to use B in A, B should be declared before A ( and the other way around ). Which class is defined first and which is second in this case ? ( without seeing your include schema I can only guess how this looks like in your code )Qt Code:
// A.h: #ifndef A #define A #include "B.h" class A... #endif // B.h: #ifndef B #define B #include "A.h" class B... #endifTo copy to clipboard, switch view to plain text mode
Try the "forward declarations" solution proposed earlier.
Yes, something like this.
As I said at the beggining of the post, I deliberately have write a code to rise an error with circular dependencies.
And my questión is: How can be possible I can build the project?
And this error means circular dependence error ?
exited with code -1073741819 = STATUS_ACCESS_VIOLATION 0xC0000005
and, a more question:
ClassA.h
ClassA.cppQt Code:
class B; class A { public: private: }To copy to clipboard, switch view to plain text mode
It works .Qt Code:
#include "classb.h" ClassA::function(){ Classb *clasb; clasb->function(); }To copy to clipboard, switch view to plain text mode
But this one not :
ClassA.h
ClassA.cppQt Code:
class B; class A { public: Classb *clasb; // I want to use in several places ... private: }To copy to clipboard, switch view to plain text mode
Qt Code:
#include "classb.h" ClassA::function(){ clasb->function(); }To copy to clipboard, switch view to plain text mode
At the second case, I have :
Invalid use in static ClassA::clasb static member.
Is that than I cannot create public or private objetcs using forward?
Thanks
If you are using an uninitialized pointer then why are you wondering why it crashes?
The above code fragment doesn't make sense at all. Forward declaration doesn't mean that you will declare the body of the function somewhere else. Read starting from here http://www.parashift.com/c++-faq-lit...html#faq-39.11
Misha R.evolution - High level Debugging IDE
Programming is about 2 basic principles: KISS and RTFM!!!
Bookmarks