Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 header files in the project: Form1.h - this is header with implementation there, TaskModel.h with TaskModel.cpp, TaskController.h with TaskController.cpp.

There are content of files:

//-----
TaskController.h

#pragma once
#include "TaskModel.h"
..........



//----
Form1.h
#pragma once
#include "TaskModel.h"
#include "TaskController.h"
.........



The problem:

How to make Form1.h to be included to TaskModel.h. When I directly include, Form1.h to TaskModel.h then there are many errors. If to use forward declaration, how to organaize that ?
Posted

You should not need to include Form1.h in TaskModel.h when the latter is already include in the former. Too many cross dependencies such as you describe are an indication that your design may need to be restructured somewhat. However, without further information as to what is defined in each header file it is difficult to suggest how best to correct the problem.
 
Share this answer
 
I've done it:

VB
// in TaskModel.h 
 
class Form1; // or other classes that are using in TaskModel.h 
 
//... task model code 
 
// in TaskModel.cpp 
 
#include "Form1.h"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900