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

learn more… | top users | synonyms

-2
votes
0answers
18 views

E-olymp: Cake. Giving Wrong Answer

Cake This is the question. While I am submitting in normal Gnu C++ then it is giving 27% accurate result and when I am submitting in Gnu C++ 4.7.1 then it is giving 8% accurate result?? What is the ...
-3
votes
1answer
58 views

8 Queens Problem

I am trying to improve my knowledge of data structures and algorithms, and have been solving programming problems to accomplish that means. This problem called "8 Queens" seemed like simple iteration, ...
1
vote
1answer
60 views

What's the quickest and most maintainable way to implement SQL querying of disparate C++ variables?

I've recently joined a team working on radar observations. The team has access to a repository of software (written in C++) used for dealing with these observations, but their work is focused towards ...
-2
votes
0answers
92 views

What is the meaning of manage c++? [on hold]

What is managed C++?. How does it differ from unmanaged C++?
0
votes
1answer
18 views

condition_variable::notify_one() thread selection

notify_one() of C++ 11 thread library is used to unblock one of the waiting threads. Question : How notify_one() chooses which thread to unblock ?
-3
votes
0answers
25 views

Using log4cxx API in C code [on hold]

I need some advices on how to use log4cxx in my C code. It looks so complicated to me, considering that I only know C, not C++. What are things I need to learn to do that log4cxx implementation in my ...
1
vote
1answer
65 views

Templating a member name

I'm writing a library that provides graphs for search algorithms. Usually you want to rank nodes using a priority queue. Normally you want to search for an specific node in the queue and lower its ...
-5
votes
0answers
37 views

Which software could you recomend for do a Artificial Inteligence [on hold]

I'm new in this page. wel.. I want to program a Artificial Inteligence, but I dont know what software use and what do I have to learn for do it. Can u help me? I was programing on java, php, sql and ...
1
vote
1answer
189 views

Inserting C++ code into C [on hold]

What I need to do before inserting C++ code into C, and how to do it? Are there any examples to show me how this can be done. I have a good knowledge of C, but never mixed those two. Thanks for the ...
1
vote
0answers
82 views

Software Design, Generic Programming, Physical Devices, and Algorithms in C++ [on hold]

I often have data that in some contexts I want to handle uniformly, but in other contexts I wish to differentiate it. For example, I could have a vector that is series of angles or a series of ...
3
votes
3answers
267 views

Idiomaticy of macros in C++

Macros are considered a good thing by one and evil by another. Is there a rule of thumb when to and when not to use macros in C++? When are macros idiomatic and when should they be avoided?
-3
votes
0answers
24 views

Help creating timers (Visual Studio 2013 C++) [on hold]

I am working on a project wherein I need to create a "timer". The "timer" runs in a separate program (from the main application the user is "working in"), and therefore, the user will enter the ...
2
votes
2answers
164 views

How do I make this functional DSL written in an imperative language more efficient?

Suppose I create a simple functional Domain-specific language (DSL) using an imperative language, in this case C++. Here is a simple implementation of a DSL that can has the notion of a simple value ...
0
votes
0answers
26 views

C++ : mixing Directx9 and default windows [migrated]

I am looking for a method of placing a DXLinked window within a windowproc as a child window. This would allow for menus/Forms controls to be externally managed before input to the DX methods. So far ...
-3
votes
0answers
38 views

Sum of a number and its digits [closed]

So I found this problem on a website and I've been trying to solve it for a few days but I must be missing on something. I work with C++. I need to find the smallest number which, together with its ...
1
vote
2answers
140 views

shared or raw pointer c++

I am developing a noSQL database and currently moving the code from C to C++. It have class Pair, which contains a raw pointer to a memory blob. class Pair { Blob* blob; ... }; Then if you add ...
3
votes
1answer
248 views

How do C/C++ programs get ported to different platforms? [closed]

Java applications can run on different platforms because they always run on top of a Virtual Machine specifically developed for each platform. So, there's no native installation, you just drop the ...
1
vote
0answers
89 views

What design pattern best suits managing handles to objects, without passing handles or Manager around?

I'm writing a game in C++ using OpenGL. For those that don't know, with the OpenGL API you make a lot of calls to things like glGenBuffers and glCreateShader etc. These return types of GLuint which ...
3
votes
1answer
70 views

How should one modularly implement related objects?

I tried to make the question title as generally applicable as possible, but I'm not certain I worded it so well. It was brought about by a very specific problem I'm having, and for the remainder of ...
3
votes
3answers
165 views

Communication between state machine and GUI

I am writing a finite state machine in C++, designed as a library. Furthermore, I have a GUI implemented as a separate project which needs to update the user interface according to state changes ...
-1
votes
0answers
39 views

Having trouble understanding/implementing backpropagation algorithm in neural network [closed]

I have a simple feedforward neural network with 2 input neurons (and 1 bias neuron), 4 hidden neurons (and 1 bias neuron), and one output neuron. The feedforward mechanism seems to be working fine, ...
15
votes
2answers
814 views

Shipping test code. Why wouldn't you?

I would like to ship unit tests alongside a product. Specifically, provide an option so that anyone with a copy of our program can hit a "self-test" button or pass --self-test on the command line and ...
-2
votes
0answers
7 views

C programming code error [migrated]

So the program is still incomplete, i cant go any further cause there is an error right after the first input, i tried using visual studio 2010 and 2015, both with the same problem: unhandled ...
3
votes
1answer
151 views

Providing views to an std::container

I want to maintain a buffer of 5 seconds of sensor data. The sensor data consists, among other things, of accelerometer readings in x,y,z dimensions, gyroscope readings in x,y,z dimension and ...
0
votes
0answers
19 views

#define as unsigned char [migrated]

I would like to know how can I tell to compiler that a #define is an unsigned char. if #define 1 byte do this: #define AACEESS_PSS 0x80 #define ACCESS_PSS ((unsigned char)0x80) but if ...
2
votes
1answer
74 views

Expandable alternative to Visitor pattern for tree traversal?

I have a tree containing various subtypes of the my base node class. I now want to traverse this tree and do something with the nodes depending on their type. The most straightforward idea is to just ...
2
votes
2answers
107 views

Member and Function Injection in C++ Across Multiple Classes

I have a problem in which a variety of classes in C++ will want some functionality that is neither a "has a" nor an "is a" relationship. The problem is that there are some members with associated ...
1
vote
1answer
77 views

OO Design: Algorithm changing State (Information Flow Question)

I have a class Context, which contains an instance of an abstract class State, which has multiple concrete subclasses (this is an implementation of the State Pattern). Each State subclass executes a ...
3
votes
2answers
98 views

How to setup build system for unit testing + mocking?

We have a legacy code base in entirely C++. Our build system is CMake. My first stab at unit testing was as follows: Define a target (LibraryA). This library contains the code to test. Define a unit ...
0
votes
0answers
79 views

audio file processing in C++

I thought of the following project that I want to pursue: I want to create a C++ program, that can play audiofiles and visualize the amplitudes of individual frequency bands in real time (e.g. with ...
0
votes
2answers
72 views

Multiple threads making call to precompiled library

I have been asked this question in an interview and I thought to take advice from you guys. Say I have a pre-compiled library which references to some function say "strtok". There is no source code ...
1
vote
0answers
75 views

C++ Template Equivalence of Prototypes [migrated]

The following compiles runs and executes as expected: #include <cstdlib> #include <cstring> #include <iostream> #include <type_traits> class Freaky { public: template< ...
-1
votes
0answers
82 views

reinterpret_cast< > from one structure to another [migrated]

I'm going through a win32 program and I found part of a code contained reinterpret_cast<> from one structure to another. What happens to PKT_HEADER* pPktHeader = ...
0
votes
0answers
39 views

Why we always have to use fgetc command in C programming instead of fscanf which do the same thing but prints strange results? [migrated]

In C programming whenever I use fgetc(file) to read all the chars until the end of the file it works. But when I use the similar fscanf(file,"%c") function it doesn't works. For example: File ...
-2
votes
0answers
19 views

Instance Variables Not Updating [migrated]

When I run my little game, battle commences but after every turn, the players attack but health doesn't go down (i.e. the game never ends and it keeps printing the same health over and over). I know ...
0
votes
1answer
75 views

Const and non-const methods, and possible mutable data member?

I'm working on a design and implementation change due to a bug. The bug fix requires us to modify a class object in a const method. I think the two options are: Have the non-const method cast this ...
6
votes
2answers
1k views

What is the difference between function() and function(void)?

I have heard that it is a good practice to write functions that do not receive anything as a parameter like this: int func(void); But I hear that the right way to express that is like this: int ...
1
vote
0answers
85 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
1answer
151 views

address and pointer of a char and int

I have been messing around pointers and addresses to understand them better, and in one compilation i got a result which i can not explain, please see below #include "stdafx.h" #include ...
0
votes
1answer
108 views

pthread versus boost::thread - need to set the thread priority on an ubuntu box

I wrote a class that basically executes a numerical analysis code in a thread using boost::thread. Now I need to specify the thread priority, since we are running a system with near real-time ...
0
votes
2answers
92 views

Usage of objects in multiple containers in C++

In cases where there is a desire for objects to be "shared" between multiple containers, I would like to know what is the best practice in C++. For example, when implementing some path algorithms ...
0
votes
0answers
29 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 ...
-4
votes
2answers
74 views

Accessing member of vector< pair<pair<int,int>, int> > [closed]

I have made a pair of co-ordinates and pair it with an index in another pair. How can I access members of these vector pairs...?? Is there any better option to implement it..??
-1
votes
0answers
104 views

Templates in c++ [migrated]

template<class T> template<typename T> T max(T a, T b) T max(T a, T b) { { if(a>b) ...
2
votes
1answer
120 views

C Module - Where to put prototypes and definitions that do not belong to the public interface?

Since I am mainly an Electrical Engineer, forgive me if I am somewhat off with some terminology. I am currently programming a display driver/interface module. And like so many times before, I have ...
2
votes
5answers
394 views

std::vector Non-Array Implementation?

I've seen some posts on the StackExchange family of sites talking about std::vector implementations. They all seem to indicate that std::vector is implemented strictly as an array (in practice), and ...
0
votes
1answer
186 views

Are ANSI* Escape Sequences Proper For Coloring Text in Terminal(Linux)?

I just switched back to Linux after a few years of Windows use and am wondering if ANSI Escape Sequences are okay for coloring text. I ask because the way I did it on windows isn't capable of crossing ...
0
votes
1answer
76 views

Flat files for events and alarms

So I'm working on a project that I was introduced to a year ago. One of the features of project involves alarming the users when certain events are triggered. There is also a log of these events. ...
1
vote
1answer
151 views

Best solution to switch between new and deprecated code

We have a feature that is currently implemented, let's call it implA. ImplA works but can't do many things. So we have decided to rewrite it. But we can't just replace it right away, so we will need ...
1
vote
1answer
84 views

Are There Tools for Statically Evaluating C++ Functions for Side Effects? [closed]

I'm interested in having a tool that can evaluate whether a function in C++ has side effects. I'd like to be able to mark functions as having or not having side effects, which I think would make ...