I have a problem with a redefinition when open a form.

From Form15 I open Form13 wich works great:

#include "Form13.h"

Form13 ^form13 = gcnew Form13;
form13->Show();

Now when I add the same code on Form21 I will have the compilererror below:
Why does this happen ?
The problem will also occur if I Only #include "Form13.h" on Form21, so the problem
starts here ?

#include "Form13.h"

Form13 ^form13 = gcnew Form13;
form13->Show();

CompilerErrors:
'Form1::Form13' : 'class' type redefinition
see declaration of 'Form1::Form13'
use of undefined type 'Form1::Form13'
left of '->Show' must point to class/struct/union/generic type

Are you using inclusion guards in Form13.h?

In Form13.h, I dont use inclusion guards. I have never used them before and I beleive the code below is inclusion guards ?
I dont know what the logic could be if using them..

#ifndef
....
#endif

Are you using inclusion guards in Form13.h?

Inclusion guards are a preprocessor trick. If a macro with a unique name for that header is not defined, proceed to process the header. If it is defined, don't process the header. The macro itself is defined during the processing of the header, so the result is that the header is only processed once:

#ifndef FORM13_H
#define FORM13_H

// Your existing header contents go here

#endif

I did get it to work. I did put this in Form15 and Form21 like this and now I understand the logic with the inclusions just to define it once for the preprocessor.
Thank you !

#ifndef FORM13_H
#define FORM13_H 

#include "Form13.h"

#endif
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.