Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
107 views

Using Composite and Visitor pattern to render a OpenGL scenegraph

I'm trying to implement a Open GL (4.6) setup with the Composite pattern (for a scene graph with Node, Cube and TransformNode classes) and the Visitor pattern (with a DrawVisitor to handle rendenring)....
Luis Angel Urena Lopez's user avatar
0 votes
0 answers
126 views

How to pass derived object as rvalue reference into base class pointer members using move constructor?

I implemented composite design pattern for calculating the nested mathematical expressions modeled in a binary tree. I need to hold two base class pointers *left,*right in my derived composite class. ...
hamid's user avatar
  • 19
1 vote
1 answer
152 views

How to avoid downcasting in composite pattern

I use a composite pattern to represent a mechanical network, which describes the mechanical behavior of a material, see e.g. the Maxwell-Wiechert model, a spring in parallel with n Maxwell Elements. A ...
StefanKssmr's user avatar
  • 1,226
0 votes
1 answer
331 views

Exception safety in the composite pattern

I used the composite pattern to represent devices, which I would like to shut down before killing their power (calling their dtor). I ran into a problem trying to group the devices, especially ...
Guy's user avatar
  • 23
0 votes
0 answers
35 views

circular dependency in composite pattern [duplicate]

Good evening, i am implementing code based on the following class diagram I am obviously facing a circular dependency problem because Document and his children use pointer to Ambit and vice-versa; i'...
francesco's user avatar
2 votes
1 answer
298 views

Using Composite Pattern to make game menu

I'm making a game menu using a composite pattern. I want to achieve a tree structure game menu, where some leaves are pushing new state on the top of my state machine and another in options should ...
IzZy's user avatar
  • 384
0 votes
1 answer
177 views

Returning Composite object of composite pattern doesn't return the whole object

I created a composite pattern with Component, Leaf and Composite Classes, where only the Composite Class has both a member variable vector and add method: void add(Component *a); vector < ...
hank7v's user avatar
  • 31
2 votes
0 answers
140 views

C++ Builder combined with Visitor

I am designing a GUI Framework based on Composite pattern (Window class inherits from UIComponent class) I need to implement a class that will create a window consisting of some UIComponents. I think ...
bzfbr's user avatar
  • 93
0 votes
0 answers
258 views

C++ Assignment composite operators vs simple operators combined with assignment operators

Someone can explain this practice to me? // no string s1("abc"); string s2 = s1 + " " + s1; // yes string s1("abc"); string s2 = s1; s2 += " "; s2 += s1; Typically, a simple operator creates a ...
Giovanni Marucchi's user avatar
-1 votes
2 answers
908 views

How to fix "Access violation reading" error?

I set up a "parent class pointer" vector with size 2 to store its "derived class" address but seem like this vector only stores final address no matter how many address i added, so its cause "Access ...
Nguyen Bot's user avatar
1 vote
2 answers
7k views

Console Application Menu with Classes C++

I am currently working on a personal project in C++, and I'm having a lot of fun learning. I just learned some ideas on using inheritance and virtual functions. I decided to create a Budget Tracking ...
Christopher Bui's user avatar
3 votes
4 answers
1k views

Composite pattern with variations in classes

I have a situation where class A, B, and C, all are derived from X to make a composite pattern. Now A, B, and C are very similar but they do have different internal attributes. My question is how do ...
zar's user avatar
  • 12.2k
0 votes
1 answer
91 views

cyclic dependency in composite structure with template specialization

Does anyone know a way to use template specialization with a custom class which is used in a composite structure? To be specific, I'm writing a program to parse/validate an XML document where the ...
Laurie's user avatar
  • 3
1 vote
1 answer
271 views

Composite pattern of std::functions

I am trying to implement a composite pattern for std::functions with use of template classes, where each composite class processes the return values of its children. So the pattern classes might look ...
Mike van Dyke's user avatar
0 votes
1 answer
1k views

c++ base constructor lvalue to parameter

I played a bit around with composite-patterns and inheritance in c++. It shouldn't be something special so i coded that a component has a parent as composite, the composite should derrived from ...
TreCore's user avatar
  • 21
10 votes
1 answer
213 views

Composite property object that inhibits multiple signal emissions when all subobjects are changed

I have a simple property<T> class with a value_changed<T> which you can connect/disconnect to and receive or inhibit events when value_changed<T>::emit(T) is called. Think Qt signal/...
rubenvb's user avatar
  • 76.4k
0 votes
1 answer
1k views

How to implement a menu using the composite pattern?

I am trying to implement a menu using the Composite Pattern, similar to what is described here. The Component declares several functions that Composite and Leaf have in common as pure virtual. The ...
Oliver's user avatar
  • 28
10 votes
3 answers
12k views

Is it alright to put data members in an interface?

Recently, I've learnt about composite pattern. I want to use it in my assignment which I have to implement File and Folder classes. I realize that sub-classes like CFile and Cfolder got to have the ...
Stoatman's user avatar
  • 758
4 votes
2 answers
184 views

Inheritance class design with "irrelevant" methods

Say I have the following abstract base class: class DLAContainer { public: DLAContainer() { std::random_device rd; mt_eng = std::mt19937(rd()); } virtual void generate(std::size_t _n) = 0; ...
sjrowlinson's user avatar
  • 3,355
1 vote
1 answer
633 views

Composite in C++ error [no matching member function to callto 'push_back']

Hi trying to do a simple composite and i am struggling with an error when trying to add one Compenent to the composite for training Here is the code Component interface Inteface for drawing ...
Mourougan Peroumalle's user avatar
0 votes
2 answers
2k views

Composite pattern with visitor, what really goes in visitor and how?

Composite pattern is often used with visitor. I am trying to figure out what exactly goes into composite and what in visitor. For example if one of the composite has unique property/attribute, will it ...
zar's user avatar
  • 12.2k
1 vote
1 answer
286 views

Is it okay if each composite item in composite pattern has lots of unique properties of its own?

Typical composite pattern books shows leaner examples (obviously) where all composite items are somewhat relatable and often use one common method name for illustration like name() in folder and files ...
zar's user avatar
  • 12.2k
0 votes
1 answer
673 views

Does it make sense to use composite pattern in tree view?

I have a tree view where every node is a different type of item - only the label and description property is the same. Does it make sense to represent each of these node item by composite component? ...
zar's user avatar
  • 12.2k
-1 votes
1 answer
123 views

Using another class as vector in a composite class

I have 2 classes, they have a composite relationship. How do I include the class as a vector in another class? Can anyone tell me how to initialize the vector as well? class Student{ int id; string ...
Coastie's user avatar
  • 55
0 votes
1 answer
56 views

OOP Approach To Buffering Data In Network App

I am working on a network library for Ethernet\IP. I am looking for input on good design strategies to assemble my packets to send them out. I am using a composite pattern to represent the pieces of ...
MDK's user avatar
  • 505
1 vote
1 answer
591 views

setVisible return false when QWidget is integrated in QQuickPaintedItem

I was facing one issue with the Widget which is integrated in the QQuickPaintedItem class. When I have Widget integrated in the QQuickPaintedItem, QWidget::isVisible will return false. If I tried to ...
Swapnil's user avatar
  • 1,558
0 votes
1 answer
2k views

error: C2146: syntax error : missing ';' before identifier 'm_Employer',

Along with Errors "C4430 missing type specifier int assumed" x2 , and C2061 syntax Errors Employer Code: Person.h #ifndef PERSON_H #define PERSON_H #include "employer.h" #...
Moon Paradise's user avatar
4 votes
3 answers
371 views

C++: Applying the Composite pattern

I am trying to apply the Composite pattern, so I need to create a Leaf class and a Composite class, both inheriting from the same Component class. In order for any of my Components to perform their ...
linuxfever's user avatar
  • 3,813
0 votes
1 answer
669 views

OOP menu system

I am trying to make a menu system (with submenus) using QGraphics from Qt4.8. The Composite Pattern sounds like a good solution but I got stuck. This is the UML diagram: https://i.sstatic.net/JgWpQ....
Vlad's user avatar
  • 45
-1 votes
2 answers
5k views

initialize a static const std::pair<string,vector<string>>

I have a class myclass { // ... static const vector<pair<string,vector<string>>> var; // ... }; in the class definition, to use mappings of single strings to several ...
npit's user avatar
  • 2,359
0 votes
2 answers
74 views

How to automatize overriding methods?

I am wondering if there is any tricky way to override all class methods in the same manner. For instance, how to wisely implement composite pattern in large classes? When i get something like this for ...
bartop's user avatar
  • 10.3k
2 votes
0 answers
805 views

Drawing on overlay window of X11 ignored by gdm/metacity

I am trying to build a smaller application that draws on top of all windows shown by the X11/x-server using cairo. I found some interesting starting points out there and got a small piece of code ...
Sebastian Büttner's user avatar
0 votes
1 answer
334 views

GOF Composite Design Pattern CompositeObject::Remove Recursive Implementation in C++

This is the part of question from my question asked in codereview website: GOF Composite Design Pattern Implementation Using Modern C++ The post has complete information/implementation about it but ...
Mantosh Kumar's user avatar
0 votes
1 answer
208 views

Iterating through a composite state list pattern

I've been trying for ages to finish this self-assigned project. My question is specifically about the "length" function, at the bottom - is there a way to iterate through the list without passing a ...
user3800586's user avatar
10 votes
0 answers
565 views

ASTs: prefer inheritance or variants? [closed]

In object oriented languages, it is fairly common to implement ASTs (Abstract Syntax Trees) using simple hierarchies (the Composite pattern), and to traverse them via visitors. In functional ...
akim's user avatar
  • 8,739
2 votes
1 answer
342 views

Operation overloading in composite design pattern in C++

Suppose I have this code all set up: class Function { public: virtual double eval(double x) const =0; }; class Polynomial : public Function { private: std::vector<double> coefficients; ...
spectral.dani's user avatar
3 votes
1 answer
431 views

Memory management in the composite pattern

I am encountering the same problem over and over, in the last weeks. Boiled down to its core, I build a (directed acyclic) hierarchy of objects like: a -> c b -> c b -> d An instance can ...
Marian's user avatar
  • 351
1 vote
1 answer
535 views

Composite pattern: Copy tree structure

I have implemented a basic composite pattern structure having three classes: class Component { }; class Leaf : public Component { }; class Composite : public Component { vector<Component> ...
LaMontagne's user avatar
1 vote
3 answers
107 views

Can some members of a class be accessible only by base classes?

I have a Widget class and a CompositeWidget that is derived from it. CompositeWidget adds child management behaviour. The Widget constructor takes a CompositeWidget* parameter as the widget parent. I ...
Dan Nestor's user avatar
  • 2,531
2 votes
3 answers
910 views

Composite with smart pointers without dynamic_pointer_cast

I implemented the composite pattern using smart pointers, it works until a point. The problem is that I just can use the methods that is implemented in the interface and I can not use the methods ...
SH.0x90's user avatar
  • 532
1 vote
2 answers
1k views

Failing to see real value in Composite/Iterator design pattern

I have situation which in theory is perhaps perfect fit for composite and iterator design pattern but the problem I have with these patterns is one can't access the underlying data structure which can ...
zar's user avatar
  • 12.2k
1 vote
1 answer
68 views

How to get ansestor's attribute in a tree structure?

I use composite pattern to implement a tree structure. It has 3 classes: node (base class), leaf (no child class), and branch (with children class). And I have some common data put in a tree node, ...
user1899020's user avatar
  • 13.5k
2 votes
2 answers
586 views

Composite pattern in C++ and C# - protected virtual methods

How can I add a protected virtual method in the "Component" class, so that it can be called from the "Composite"? As an concrete example, look at the code below, and please tell me how to avoid the ...
Andrei Bozantan's user avatar
0 votes
1 answer
524 views

C++ Inheritance & composition used together

I have class A, having methods that update properties of B. So, I need inheritance. class B{ public: int x; }; class A : public B{ public: void update(int y){ x = y; } }; I also want to reach ...
baci's user avatar
  • 2,578
2 votes
1 answer
1k views

C++11 Composite Pattern with Smart Pointers

I am working on a personal project to familiarize myself with C++11 and Boost. I have a inheritance relationship with a UrlExtractor base class, with a TagUrlExtractor derived class and a ...
Travis Parks's user avatar
  • 8,695
0 votes
2 answers
719 views

Dereference iterator as part of a boost::bind composite chain

I am trying to use bind to produce a function that: Receives a map m returns m.begin()->first For that I am trying to use boost::bind: typedef map<int,int>::const_iterator (map<int,int>:...
ricab's user avatar
  • 2,792
3 votes
1 answer
4k views

Composite, component and entities in C++ game engine

I'm working on a school project developing a game. We use an engine made by one of the teams we have. The build-up of the engine is unclear to me and seems an anti-pattern. However, it seems that no ...
RB-Develop's user avatar
7 votes
4 answers
1k views

Solving design involving multiple inheritance and composite classes in c++

I have struggled with this design problem for some time. I will do my best to explain what I am trying to do and the various approached that I have seen, what I am trying and why. I work in a ...
PhiloEpisteme's user avatar
0 votes
1 answer
101 views

[C++]How to use std::stack to deal with the file/directory hierarchy?

I have 3 class, Root, CFile, SubDirectory. Root is a abstract class. CFile and SubDirectory are derived from Root. CFile has attributes: name:string , size:int, level:int. SubDirectory has attributes: ...
Qianyi Wu's user avatar
0 votes
3 answers
644 views

cannot convert parameter 1 from 'PrintVisitor *const ' to 'Visirot &'

I used two design pattern Composite and Visitor. I have no problem with Composite.But when he began writing derived classes for input and output got some errors, solution which I did never found. ...
bilenkuyboy's user avatar