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

learn more… | top users | synonyms

-3
votes
1answer
48 views

Generate this kind of 2d burst or pulse algorithm?

I'm currently trying to develop a game using Cocos2d-x using C++ I really need to generate this burst or (donut-shaped) pulse. I'm having a difficult time how to generate such shape. At first, I was ...
-4
votes
0answers
70 views

What's the speed in orders of magnitude of managed code [on hold]

Since i got this link, I got my answer in part, so ill try to reformulate it: Where is managed Code faster, where is it slower compared to normal unmanaged code. It seems, allot of work went into ...
2
votes
1answer
112 views

How does this C++ assignment work?

I have very limited experience with C++ but I do have plenty of experience with Java and NodeJS. I've decompiled and tried to make sense of a small C++ compiled file and I've come across something ...
0
votes
0answers
64 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 ...
1
vote
1answer
63 views

Get or infer template type from inherited member

So I have an assignment from college where I have to apply multiple metaheuristics to different problems. I thought that I should make everything as modular and reusable as possible to reuse ...
3
votes
4answers
205 views

When should a function take a pointer for a collection to fill vs returning a pointer with a filled collection?

In C++ I frequently see these two signatures used seemingly interchangeably: void fill_array(Array<Type>* array_to_fill); Array<Type>* filled_array(); I imagine there is a subtle ...
4
votes
1answer
123 views

Word ladder efficency problem

I have a problem dealing with word ladders. The problem is: given two words and a dictionary file, find the shortest word ladder between the two words. So if given the words cat and pot: cat -> ...
0
votes
0answers
7 views

Can't find a source file […] allocator.h [migrated]

I am trying to debug a debug example code, which is part of a C++ course materials, with Eclipse. However, once a certain line of the code is reached, this message is displayed and the the rest can't ...
-2
votes
0answers
47 views

How to parse multiple xml files in a folder [closed]

After having some discussions with some others, it seems that a licensing project I'm going to be working on is going to rely on multiple xml files (one for each licensed app/feature) to identify and ...
-4
votes
0answers
72 views

How do I do this? [closed]

I am fairly new to coding. I would like to know how (in C++) to connect a form to a C++ project so when I run the program I get the form and not a console. How do I do this?
0
votes
2answers
121 views

Naming when having to inherit classes [closed]

I am always a huge fan of standards and think I finally decided on one of the many C++ naming standards. However, it almost seems moot because working with a couple of libraries where the standard use ...
0
votes
1answer
96 views

CreateFileMapping() - parameters of size

I want to make a program, which will put some sentence in shared memory so another program will receive this massage. I made that, but I do not understand the 4th and 5th parameters of ...
2
votes
0answers
52 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
1answer
76 views

What is MISRA 8-0-1 rule on init-declarator-list and member-declarator-list about?

I am reading company's coding guidelines, and I encountered the MISRA 8-0-1 rule, which states: An init-declarator-list or a member-declarator-list shall consist of a single init-declarator or ...
2
votes
2answers
310 views

Could someone write an opensource version of the Windows API?

I am wondering if it is both possible and how one would write an opensource version of the Windows API. What I mean by this is, say you #include <Windows.h> in your C++ application. Then you ...
1
vote
2answers
62 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 ...
4
votes
2answers
125 views

Design question about hiding implementation from users of a dynamic library

I'm building a DLL and in my public headers I have this: (definitions are in .cpp but for clarity I show them in .hpp here) ObjectTag.hpp: class API_DLL ObjectTag { public: ObjectTag() : ...
1
vote
3answers
297 views

Do I have to fork a server program as an “C” child process in order for correct interprocess communication to take place?

I would like to implement interprocess communication between an Ubuntu Linux 15.10 mono 4.1.2 C# recorder client and Ubuntu Linux 15.10 mono 4.1.2 C# video server using a C++ mutex class and C++ ...
1
vote
1answer
126 views

Does having so many macros (#define) increase compilation time due to prolonged pre-processing?

In a very simplistic way, I understand: "Compilation" = "Pre-processing" + "Parsing" + "Linking" + "Executable" All the macros and other such pre-processing directives are taken care at the ...
0
votes
0answers
9 views

Conversion of temperature from Fahrenheit to Celsius [migrated]

This is my program for conversion of temperature from Fahrenheit to Celsius (with one degree increment in Fahrenheit). Apparently it seems all right to me. But it is displaying 0 for all Celsius ...
-3
votes
0answers
22 views

boost mpi reduce for std::complex<long double> array [migrated]

Does anybody out there have idea about doing reduce for std::complex<long double> array using boost? I am getting error ‘struct std::complex<long double>’ has no member named ‘serialize’ ...
1
vote
2answers
169 views

Why doesn't the compiler complain when I try to access a non-existent array value?

My C++ book says that if I have int anArray[25]; and I try to evaluate anArray[25] = 0; the program will simply overwrite whatever value is stored in the next memory address past the end of the ...
0
votes
0answers
69 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 ...
-1
votes
0answers
60 views

Design approach for multi-shape graph nodes drawing

I am using Qt C++ to draw graph which represent and electronic circuit. The problem is that not all nodes have the same shape, I have 2 kind of nodes (circle, polygon), there is an edge class and node ...
-3
votes
0answers
84 views

net-snmp: how to set sysUpTime [on hold]

I've been googling and searching this group as best I can but I cannot find an answer. I'm using net-snmp and sending version 2c traps. Apparently the "sysUpTime" variable is compulsory though I ...
2
votes
3answers
147 views

Adding a function to class member

I'm not sure of the proper terminology here so I'm having trouble finding the answer to my question but here is what I want to achieve. say I have class ABC { public: int number; }; and I ...
-2
votes
1answer
67 views

Static Polymorphism explained

Here is a code I have got from here: class Deletor { public: virtual ~Deletor() {} }; template<typename T> class Base : public Deletor { public: int Run() { return ...
5
votes
2answers
349 views

Why is threading platform-dependent?

I am reading book "Foundations of Qt Development", Chapter 12, and I read that threading is platform-dependent, can someone explain, why? I know how to use threads but that what they said is not so ...
2
votes
3answers
145 views

When to mark a function as virtual?

I'm trying to understand the idiomatic way to code. I'm using gmock to unit test the components I write. Gmock requires methods to be virtual to be able to mock but the class I'm trying to mock has a ...
2
votes
2answers
115 views

How to write unit tests for network client?

I need to write simple http client. It could be great to have unit tests for my class. But I don't know how to write proper and testable class. For example, I have a client like this: class ...
4
votes
3answers
124 views

How should I write an interface that takes a list of items?

I'm writing a library function that takes a list (or "bunch") of items (let's say Student) and does something with them. What's the best way to write the function signature in the interface? ...
3
votes
2answers
206 views

How to stay DRY with return values

I have a bunch of repetitive C++ code that looks like this: // Compute finalOutput if possible. Return true if successful, false otherwise // finalOutput only holds a valid value if true is returned. ...
5
votes
3answers
224 views

How aggressively to change in-house smart pointer to unique_ptr?

I work on a large software product which, being over 20 years old, has a number of constructs which have been superseded by language updates. One of these is a home-rolled smart pointer template ...
3
votes
1answer
304 views

Why double colon instead of dot?

It is rumoured that early C++ implementations have had dot operator for namespace access. There is an opinion that the dot is more convenient that the modern double colon operator. What was the ...
1
vote
2answers
81 views

Catching exceptions from child process

I am looking for any info. (I know some C++ with win32 and C#) The Idea: The idea is to help a program with missing files load. In the end I wanted to see if I could have my program launch a simple ...
-2
votes
3answers
175 views

Is it possible to have private or protected objects in Java? Or are all objects considered public?

Is it possible to have private objects? For example, when you instantiate an object (classType object1 = new classType()), can that be private or protected or is it always public?
0
votes
1answer
99 views

Find if certain files have been added or removed in large directory structure

I have a larger directory structure (dir + sub directories) with files. It contains files of certain types. For one particular type (let's say with appendix .foo) I need to figure out if files have ...
0
votes
1answer
87 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
0answers
60 views

Client-Server app architecture with custom communication protocol

I am working on Qt/QML/C++ based Client-Server software system with custom protocol. Now, in both projects inside QtCreator I have same header and implementation files inside both projects. What is ...
0
votes
5answers
248 views

Is there a better way to debug while avoiding getters/setters?

I'm thinking about how to debug better without using Getters/Setters. If it helps, I program using xcode. Many answers in Stack Exchange have argued against Getters/Setters for lack of encapsulation ...
2
votes
2answers
440 views

Should we “balance” the amount of codes between headers and cpp?

As far as I know, cpp usually contains far more codes than headers, mainly because they contain implementation details of functions instead of just one line of function definition. Here comes to my ...
-1
votes
0answers
45 views

How to convert a JNI unmanaged native dll to managed dll?

I have been tasked at work to convert a JNI DLL to a managed DLL that can be consumed by VB6, VB.net, C# , C++, python, etc... I have looked around here and found some comments about swig. I also ...
12
votes
1answer
296 views

Should I add the source of libraries instead of linking to them?

I'm relatively new to C++, so I'm not sure how I should best handle small dependencies (e.g., a scripting language, or a JSON/YAML/XML Parser). Should I create separate projects and link them as ...
8
votes
5answers
539 views

Is it correct to say that a variable is an instance of a data type?

(that can change its value over the course of the program) Or is 'instance of something' strictly related to classes and objects? If so, how would you define the concept of 'variable' when it comes ...
1
vote
3answers
406 views

Which languages allow to mix its source code with C++ source code?

I have read that there are languages other than C++ that can also compile standard C++ source code too (Objective C++ can do this). Which other languages for Windows and Mac OS are there, that support ...
7
votes
1answer
70 views

Visitor Pattern, replacing objects

I have a program that translates a DSL to C++, which uses a Visitor pattern on the intermediate representation. I quite often need to replace the currently processed node with one of a different type ...
1
vote
0answers
80 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 ...
0
votes
2answers
126 views

C++ class vs function header file

I'm using C++ for implementing a project that requires to import a file once. All the data in this file needs to brought in memory as key value pairs, but only when the file is imported. Since this ...
5
votes
1answer
106 views

Algorithm to find span intersections in a sorted set

I have a set of items strictly ordered on time. Each item can either be single (no Next, no Previous) or part of a span (with either 1 or 2 further endpoints). For example in the picture A is part ...
3
votes
4answers
227 views

Is Template Pattern a good way to implement DRY?

Here is my problem: I have and class structure like this: class Base { private: SomeType something; bool isSomeValue; public: virtual void myMethod() = 0; ...