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

learn more… | top users | synonyms

-1
votes
0answers
11 views

Keyboard input errors while running

I'm having issues with a program that was originally written in Visual C++ 6.0. The program builds and runs fine, until I attempt to enter values into the command line. I believe that I have isolated ...
20
votes
3answers
1k views

Does a `long` ban make sense?

In today's cross-platform C++ (or C) world we have: Data model | short | int | long | long long | pointers/size_t | Sample operating systems ... LLP64/IL32P64 16 32 32 64 ...
0
votes
2answers
104 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 ...
1
vote
2answers
103 views

How does long long syntax work when int int doesn't in C++?

I was wondering if long long specifies a single datatype then why don't things like int int work? I meant obviously that's not a data type but there is a long data type. Essentially what I'm asking ...
0
votes
0answers
60 views

Algorithm to fit all items in a bag choosing most optimal cost?

Is there any algorithm to do this? I have objects that have attributes, maybe some weight, type, etc. I need to place the best configurations possibles where all my objects no matter the type fit, ...
-3
votes
0answers
51 views

Reading quality code to learn [on hold]

I'm currently studying the C++ programming language by using the book: Programming principles and practice using C++. I'm at chapter 12 now and after some hard work I've got the basics of what makes a ...
-5
votes
0answers
72 views

Kindly comment this line of code [on hold]

Code: //lookup the chunk lookup(chunk_t e):elem(e) {;} Kindly comment this line of code. What does it mean? The function and what is it pointing to?? Thanks
2
votes
5answers
334 views

What is the best way to save data of a C++ Program ? Binary vs JSON serialization

We are implementing a CAD program (in C++, Qt) where we have interdependant classes : The smallest brick is the Pattern, it is just a distribution of points. Then we have Layouts which contain ...
1
vote
2answers
80 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
0answers
17 views

Unexplainable bug in my code [migrated]

So I'm trying to write a small application that changes a line in registry to enable a certain thing.. Here is my code. #include <iostream> #include <Windows.h> DWORD transparenton = ...
-2
votes
0answers
51 views

Cython vs Rcpp for science [on hold]

I am future ecology PhD student. I am focusig on mathematical and computer ecology. Models in my diploma thesis were written in pure R. I really enjoyed graphics options of R but I hate R's speed. I ...
6
votes
3answers
3k views

Is relying on implicit argument conversion considered dangerous?

C++ has a feature (I cannot figure out the proper name of it), that automatically calls matching constructors of parameter types if the argument types are not the expected ones. A very basic example ...
-2
votes
0answers
40 views

Handling class types when creating a scripting language in c++ [on hold]

I've been stumped by this for some time although I believe it may be quite simple. I am writing a simple programming language in c++ and I can't figure out the best way to handle variable types ...
2
votes
0answers
67 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 ...
28
votes
7answers
3k views

C++ skills higher than C skills? [closed]

I feel that the often seen C/C++ doesn't really describe my skills in my CV. So I'm planning to separate it into advanced C++ knowledge and mediocre C skills. Do you think this is confusing for the ...
8
votes
5answers
4k views

GO instead of C/C++ with cgo

Is it possible to replace C and C++ with Go + cgo and interface frameworks such as Qt or DirectX with Go? Any potential pitfalls I should be aware of? UPDATE: I see that my question was not precise ...
127
votes
7answers
150k views

When do you use float and when do you use double

Frequently in my programming experience I need to make a decision whether I should use float or double for my real numbers. Sometimes I go for float, sometimes I go for double, but really this feels ...
0
votes
1answer
94 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 { ...
-4
votes
1answer
73 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 ...
2
votes
1answer
150 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
79 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 ...
3
votes
4answers
224 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 ...
1
vote
1answer
71 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 ...
0
votes
1answer
102 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 ...
1
vote
5answers
6k views

How to share memory between applications written in C/C++

I'm going through a program written in C/C++ for control in robotics. Basically, three different programs run at the same time, and they communicate via shared memory. Google-ling around I found ...
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 -> ...
1
vote
2answers
63 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 ...
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 ...
1
vote
3answers
301 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++ ...
0
votes
2answers
122 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 ...
2
votes
0answers
53 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
2answers
315 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 ...
2
votes
1answer
81 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 ...
4
votes
2answers
127 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() : ...
19
votes
8answers
843 views

Dealing with coworkers when developing, need advice [closed]

I developed our current project architecture and started developing it on my own (reaching something like, revision 40). We're developing a simple subway routing framework and my design seemed to be ...
1
vote
1answer
130 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 ...
0
votes
1answer
224 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 the ...
-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’ ...
21
votes
5answers
13k views

JIT compiler for C, C++, and the likes

Is there any just-in-time compiler out there for compiled languages, such as C and C++? (The first names that come to mind are Clang and LLVM! But I don't think they currently support it.) ...
-3
votes
0answers
90 views

net-snmp: how to set sysUpTime [closed]

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 ...
1
vote
2answers
172 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 ...
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 ...
0
votes
0answers
70 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
62 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 ...
2
votes
1answer
259 views

Feeding std::streambuf for Non-Blocking std::istream Read

I want to write small library to guide a child process for a specific needs (not trying to reinvent bicycle here). My needs includes reading from child stdout and stderr. I want to implement this as ...
3
votes
1answer
311 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 ...
5
votes
2answers
356 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
7k views

Is there still any value in learning assembly languages today? [closed]

Specifically for a game programmer. If you really needed some assembly routines you could look for help, whereas back in the 80s/90s it was one of the mainstream languages. I read that compilers can ...
2
votes
2answers
119 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 ...