Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:14:45+00:00 2026-06-17T19:14:45+00:00

I have 3 classes. The main class is Form1 The other two are Form2

  • 0

I have 3 classes.
The main class is Form1
The other two are Form2 & Class3
I included Form2 & Class3 in Form1, I mean I have in Form1 the following:

#include "Form2.h"
#include "Class3.h"

Also, in Form2 I included Class3, so I have in Form2 the following:

#include "Class3.h"

But I get redefine error, how I can solve this.

I always face like this issue, some time it is enough to include headers in stdafx.h but sometime doesn’t work. So the other question how I can utilize and make use of stdafx.h which is created by default in my C++/CLI winform project?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:14:46+00:00Added an answer on June 17, 2026 at 7:14 pm

    Try adding this in Class3.h:

    #ifndef _CLASS3_H
    #define _CLASS3_H
    
    /* your code here */
    
    #endif
    

    That should work

    So you understand what is going on, what this is doing is preventing your Class3.h to redefine everything if it has already been done. In your program, Form1 uses Class3, but so does Form2. The first time Form2 is included, so is Class3, then, the next line you try to include Class3 again and then you get a redefinition error.

    Hope that makes it clear for you

    p.s.: I strongly recommend that you do this with all your .h files, though

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main class and two extended classes: class Main { public $foo;
I have a java application where main class is dependent with some other classes.
I have 3 classes in my example: Class A, the main activity. Class A
Example: For(int i=0; i<4; i++) playSound(Sound.wav); I have the following classes: Main import java.io.IOException;
I'd like to have two main classes (or more) with leiningen, and then be
Starting to learn Canvas and have two classes so far (main one to call
I have two classes, derived from a common class. The common class has a
Using: C#, VS2008 I have the following main form class: [Main.cs] namespace Server {
In my application's Business Logic layer I have the following classes: public class EocMonitor
I have a OOP question. I have 3 classes. Program (main class), login form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.