Questions about C++, a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

learn more… | top users | synonyms

4
votes
2answers
158 views

Why does ifstream.eof() not return TRUE after reading the last line of a file?

When a beginner starts off reading ifstreams, his/her instinct is to read the file using a loop that usually looks like this: while (!ifstream.eof() { ... } However, C++ programmers note that what ...
1
vote
2answers
74 views

Implementing an event scheduler for animations

The basic idea is to have some animated widgets that sit in a container, quite similar to Qt (the only actual difference is that my widgets are animated). The animation is in some cases dependent on ...
1
vote
2answers
115 views

How to store state data when the data is related to another entity?

In order to increase the parallel-ability of my objects, I try to make them read-only and include only data that naturally belong to the entity. I have class Object { ... }; class Processor { ...
1
vote
2answers
85 views

Dynamic gesture recognition with fingertip points

I have built a fairly robust program in c++ which tracks several points on a hand. It accurately quantifies the size of the palm, the center of the palm, and the fingertip locations among other hand ...
0
votes
2answers
40 views

Best Communication strategy for monitoring dashboard

I have a requirement where I need to display certain stats on Admin Dashboard in my web application (Angular+Java). These stats (transnational data) are being generated on different servers (connected ...
0
votes
2answers
108 views

The way to implement a configurable (at run-time) default style

I am coding a visualizer of graph algorithms. Each vertex of the graph has a style (color, size etc.). As long as the algorithm has done nothing to a vertex, that vertex has a default style. The ...
0
votes
1answer
278 views

C++, header files and using namespace std

So I understand that one must not use using namespace std; in header files. Well for my assignment we have to overload the >> operator. I got my program to run and all, but I had to include ...
-1
votes
1answer
797 views

Use of pdb file in release build executables

This question is appropriate only for programs created on the windows platform. If I build a release of my program with the /Zi option (create pdb file and store path to file in exe) then I don’t ...
-2
votes
1answer
697 views

Bresenham Vs Midpoint Circle drawing algorithm

Can somebody explain the difference between Bresenham and Midpoint Circle drawing algorithms? All I am able to understand is that in both algorithms we compute coordinates of an octant instead of ...
4
votes
0answers
503 views

Dynamic programming in Bin packing

Problem: Given a list L of objects of possible sizes from set S={1,2,4,8} and unlimited supply of bins of sizes 16 each and we have to use minimum possible numbers of bins to pack all objects of L. I ...
3
votes
0answers
587 views

Is it rational to convert protobuf into json to send it to a web server?

Protobuf is a good thing, it allows c++ devs to not bother with class serialization/deserialization, is fast and .proto format is very nice. It also allows automatic data validation. But the messages ...
2
votes
0answers
64 views

How to combine template and inheritance

I have multiple factories, each is responsible for creating instances of an inheritance tree. For example (syntax or semantics maybe incorrect), struct InterfaceA {}; struct ImplA1 : InterfaceA {}; ...
2
votes
0answers
83 views

What are the benefits of an input/output component design?

For the company I work at, all of our projects, including a new one started last year, are written in C89. We write for vxWorks (a real time embedded operation system). Our software runs ...
2
votes
0answers
56 views

Default move assignment and destruction order of members versus the rule-of-zero

Members must frequently be destroyed in the correct order. As member creation is in forward order and destruction is in reverse order this will usually work fine. However, when assignment operators ...
2
votes
0answers
114 views

Speed: Named Shared Memory vs Memory Mapped File vs Normal Memory

Let's say I have a server, where clients who connect are constantly updating their inventory. I could simply save the changes in to the database after an item has been updated, or I could update the ...
2
votes
0answers
44 views

How to architect rule matching with multiple conditionals and outcomes

I'm working on allowing my users to create their own ruleset for data that's coming in. All of the data below is sample mock data and not in relation to our product. Example of a rule (there can be ...
2
votes
0answers
56 views

Visual interpolations: independent or linked to object?

I have a class that I use to render GUI elements on the screen, this class has a tree structure (with children, parent, and siblings). I created an additional class which allows me to interpolate some ...
2
votes
0answers
162 views

Requesting information regarding the use of MUI vs. the use of GetText for i18n/L10n of Windows desktop applications

I have spent the past two days investigating which technology I will use to support translations of text strings (as part of an overall internationalization migration) for an archaic (VC6) Windows ...
1
vote
0answers
18 views

Using and designing asynchronous APIs with naturally synchronous parts

I've been programming for a long time, but very rarely with anything asynchronous (and not often with anything to do with multithreading, either). Mostly for the fun of it, I'm writing a program to ...
1
vote
0answers
82 views

How to structure enum data to achieve the desired effect

I'm making a framework for building simple html websites for an embedded system and I want to make it bulletproof in a way that a user can't make mistakes in building the html document. As I've ...
1
vote
0answers
95 views

Pure abstract classes for input-, output- and bidirectional-pin of microcontroller

I'm writing a real-time operating system for microcontrollers in C++11 - distortos. Currently I'm thinking about a C++ framework for various peripherals. The most basic peripheral which I would like ...
1
vote
0answers
171 views

What is the “async desaster” Detlef Vollmann was talking about at Meeting C++ 2014?

I found the slides of his talk there: https://meetingcpp.com/tl_files/2014/talks/executors-meetingcpp.pdf In one of the last pages, he is talking about the "async desaster" (which I, as a non-native ...
1
vote
0answers
131 views

Switching from Node.js class techniques to C++

I'm going to be rewriting a project from Node.js into C++11. The device the Node.js scripts are being run on are ARM based, and Node.js is slow to start up on the device. In the Node.js program, I ...
1
vote
0answers
432 views

Integrate C++ DLL with C# GUI asynchronously (design issue)

This is more a design than an implementation question. I am aware of how to integrate a C++ DLL within a C# main app that acts as GUI. Believe me that I've read all other questions on similar topics, ...
1
vote
0answers
84 views

Pointers vs IDs for “context-specific” functions

I need to be able to load, use, and free resources from a single monolithic object. I have two requirements: 1. That the resource loaded is owned by the object that created it and 2. All objects in a ...
1
vote
0answers
252 views

Best software architecture for an efficient network tunneling in C++

Before jumping to my questions, let me explain my project's background. I am part of a team that organize the network of a famous LAN event. Most of the games nowadays actually don't run locally but ...
1
vote
0answers
88 views

Maximizing reuse out of a function primitive in CUDA

I'm working on the implementation of a few related algorithms in CUDA, all of which require a primitive that we'll call f(). The related algorithms can't simply call f though, as they require f to ...
1
vote
0answers
202 views

Mailbox Pattern with Variable Arguments in C++

In a game I'm developing, the GUI thread is catching user actions, and the simulation thread is responsible of handling and responding to them. To minimize complexity and delay, I predefined all ...
1
vote
0answers
325 views

In-place merging of sorted intervals in an array?

So I have code producing k sorted intervals in an n-sized array. What I'm brainstorming is the possibility of in-place merge of these intervals into a single sorted interval/array. The problem is ...
1
vote
0answers
120 views

Web Services of System Integration

I have been assigned to a system integration project. However, I do not understand part of the integration implementation architecture. For example, I have a passport scanner connected to a Windows ...
1
vote
0answers
130 views

Representation of time expanded graph

I want to build a time expanded graph with time discretization Dt that starts at t = 0 and ends at t = T where between the node (n1, t) and the node (n2, t') is an arc if and only if (n1, n2) were ...
0
votes
0answers
16 views

Creating and passing new object in parameter

I have a wrapper class which contains a smart pointer (unique) which can point to objects which are subclasses of State. Each subclass of State receives a reference to the wrapper class so that the ...
0
votes
0answers
85 views

Building a heap in C++

I am learning heaps in C++ and I have a question about heapify function. So in order to build a heap from a random array, you put the elements from the array in a binary tree in order in which they ...
0
votes
0answers
71 views

Arbitrarily sized (and signedness) integer arithmetic in C++ - How can it be done generically at runtime?

How can I efficiently handle integers of unknown size and signedness in various arithmetical operations in C++? (for a virtual machine). I am storing the program for the virtual machine in a string ...
0
votes
0answers
103 views

What to unit-test when loading a dll?

I wrote a wrapper class that is using a dll. I have a LoadLibrary() function and have wrapped all the functions the dll exports (to match my error codes). I am not too familiar with unit testing. I ...
0
votes
0answers
44 views

Is it possible to maintain one code base and deploy on both spir/open-cl and ptx/cuda?

It is my understanding that both spir and ptx are based on llvm. Binaries can be generated by clang for use along with the native graphics compute drivers (e.g. open-cl and cuda). My question is ...
0
votes
0answers
88 views

How to improve the design pattern of this Screen Window system?

I have a Screen Window system, a Screen (IScreen as interface), which holds a window, either WindowA or WindowB. System can switch window by calling stateChanged: class IScreen{ public: virtual ...
0
votes
0answers
135 views

Qt / C++ internal API design for slightly similar web services

in my application I provide a Qt/C++ wrapper to certain web services based on the Danbooru software. Basically the API wraps a series of REST calls and produces / parses the JSON responses to display ...
0
votes
0answers
141 views

How can I automate updating code on an integrated device with files and a MySQL database?

I have an integrated device that has a program in it currently written in Node.js. So, naturally, there are a whole bunch of files that it needs to run. Also, there is a MySQL database that it uses ...
0
votes
0answers
77 views

Why are datatypes different in terms of bit size based on complier, and OS used

I was reading a tutorial on C++ as I am new to programming, and I was wondering why the sizeof operator gives different output depending on what you're programming with.
0
votes
0answers
56 views

Mocking delegate constructors

I am new to Unit Testing in C++. I am supposed to write a Unit test for my code and I am using Google Mock for the same. I have gone through their turtle example. But I am still confused as to how to ...
0
votes
0answers
83 views

Matching groups of similar lines on a generic matching algorithm

I have to write a program to search through a file containing lines and find lines that match to a degree of tolerance but are not necessarily the same. So for example the following lines would match: ...
0
votes
0answers
255 views

R* Tree work with dynamic data

I'm searching an algorithm to store my data (which are moving objects' coordinates) and allow me to query objects within a specific radius of a specific point. I came up with R* Tree which is said as ...
-1
votes
0answers
88 views

Calling an entire script (in C) from another script (in C++)?

I am a very inexperienced programmer, so apologies if this is a stupid question to be asking. And similarly, if anyone answering could assume that I know basically nothing at all and treat me like an ...
-1
votes
0answers
20 views

tidyParseBuffer strip the <style> tag in the body

When i use "tidyParseBuffer" function to parse a html, it remove the "style" tag in the body, usually the "style" tag should be in the head, but i need the contents in the body, what should i do to ...
-1
votes
0answers
52 views

Integrating IDE with docker C++ toolchain

I have created a docker in order to compile C++ applications using a third party toolchain. My ideal work environment would be to leave the sources on my local directoy and to use the docker only for ...