FAQ Database Discussion Community


Is there any way to declare mutual friend functions for two classes

c++,circular-dependency,forward-declaration,friend-function
class CDB; class CDM { public: friend CDB& CDB::Add(const CDM&); CDM& Add(const CDB&); }; class CDB { public: CDB& Add(const CDM&); friend CDM& CDM::Add(const CDB&); }; This code gives me the error : error C2027: use of undefined type 'CDB'. How to resolve this....

How to solve a circular class dependency with shared base class without headers?

c++,c++11,visual-studio-2012,circular-dependency
So I am creating a project that involves having vectors nested inside one another, but the structure won't compile. I think this is a case of circular dependency, but all of the fixes I've seen seem to only apply to code involving header files and separate translation units. #include <iostream>...

RequireJS, Circular Dependencies and Exports “Magic” Method

javascript,requirejs,circular-dependency
I've been trying to get RequireJS set up to handle circular dependencies using the special 'exports' magic module as recommended by James Burke's answer to this question. Following the example given by @jrburke in that question: define("Employee", ["exports", "Company"], function(Company) { function Employee(name) { this.name = name; this.company = new...

Incomplete pointer used in child class - Error: use of undefined type

c++,pointers,inheritance,protected,circular-dependency
Okay... I have understood this question about circular dependency and forward declaration, but I am having trouble understanding a particular error that involve inheritance and pointer-based variables. I will show snippets of the relevant code: Player is the derived class from Entity Entity.hpp class Entity : public sf::Sprite{ private: int...

requirejs circular dependencies and function objects

javascript,requirejs,classloader,circular-dependency
Is it possible to differentiate between dependencies which are needed on structure build (like inheritance) and runtime dependencies (within a method call). A little example: 2 "classes": Father and Child which depend on each other Father.js define(['Child'], function (Child) { function Father() {}; Father.prototype.childs = []; Father.prototype.addChild = function (c)...

Simple Makefile reporting circular dependency — possibly from suffix rules?

makefile,make,gnu-make,circular-dependency
I'm using mingw32-make and attempting to create a simple rule to run windres to include an icon for a Windows executable. The structure consists of a simple C program in a.c, an a.rs file containing only the line: 1 ICON "a.ico" ..the icon file itself, and the Makefile. The Makefile:...

Avoiding circular dependency problems when using templates

c++,templates,circular-dependency
I have encountered a problem, which is most likely caused by a wrong forward declaration of circular dependent classes. But forward declaring template classes (similar to here seems to still not work. With visual studio express edition 2013 I get a LNK 4221 warning (no new symbols defined) which causes...

How to handle circular dependencies in typedef'd structures

c,struct,circular-dependency
I have two modules, a and b. a.h: #ifndef A_H_ #define A_H_ #include "b.h" typedef struct { b_t *b; ... } a_t; #endif // A_H_ b.h: #ifndef B_H_ #define B_H_ #include "a.h" typedef struct { a_t *a; ... } b_t; #endif // B_H_ How do I alter this so that...

Handling Jackson circular dependencies using a context stack instead of using JsonIdentityInfo, or JsonBackReference & JsonManagedReference

json,serialization,jackson,circular-dependency,circular-reference
I am using Jackson to serialize JSON, but my JSON clients are not Java, and don't use Jackson. I want to avoid circular reference serialization infinite recursion by, whenever serializing a whole bean would cause an infinite recursion, serializing the id of the bean instead of the whole bean. This...

Gradle file rename causes circular dependency error - Why?

gradle,circular-dependency
I want to store an input file in a JAR created with a subclass of the Jar task in Gradle. The input file shall be stored under a different name. Here is my build.gradle (complete working example; just create dir1/file1.txt first): task myjar(type: MyJarTask); class MyJarTask extends Jar { @InputFile...

requirejs returns undefined without dependency

requirejs,undefined,marionette,circular-dependency
On some occasions, requirejs returns an undefined object to my module. I've looked at a number of posts and most of the answer are related to circular dependencies. However I could find none (I have checked several times). I apologize by advance for pasting a quantity of code that I've...

How to have a class contain a list of pointers to itself?

c++,list,linker-error,circular-dependency
I'm making a game in C++. In this game, there is a list of GameObject pointers. GameObject is the base class for every object one may interact with in the world. Main's job is to act as the referee, so it informs each object about collisions, renders them, deletes them,...

C++ Is there a way to work around circular dependency?

c++,circular-dependency
Now I know that in C++ everything has to be declared before it can be used. But what if I have two functions that reference each other? For example: void func1() { func2(); } void func2() { func1(); } Is it completely impossible to do this?...

Breaking cyclic dependency in constructor

java,dependency-injection,dependencies,circular-dependency,decoupling
I'm writing a Java class to manage a hex map (class GameMapImpl implements GameMap) that contains Cell objects. Cell objects are saved in a HashMap<Hex,Cell>, where the key is the position on the hex map. The whole thing used to be very tightly coupled between cells and GameMap, with a...

Circular Path algorithm

algorithm,order,path-finding,circular-dependency
I am stuck at developing a circular path algorithm creating a path out of points. This is the array I am starting with: (1,1) (1,6) (2,2) (2,5) (4,1) (4,2) (6,5) (6,6) These are points in a coordinate system and I want to be ordered so I only need horizontal or...