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

learn more… | top users | synonyms

-2
votes
0answers
24 views

Why can't I debug this in code::blocks?

I have the following program and I want to debug it. #include <iostream> #include <cstdlib>> using namespace std; void display(char charArray[], int SizeOfArray); int main() { char ...
-2
votes
0answers
49 views

Big Projects in C++

After so much digging, i am asking THE question which is on my mind from almost an year. Just look at this list List of c++ softwares 10 best c++ softwares My question is, How these are ...
-2
votes
1answer
89 views

What is a good OS for getting maximum performance out of a C++ program? [on hold]

I am looking to run a C++ program without any interference (context switching) from other processes. Is there a small operating system that will allow me to stop all other processes? Is there a bare ...
3
votes
0answers
54 views

Compiling for string and wstring

I'm creating a library. I want to use it in multiple projects which may use multi-byte or unicode (std::string or std::wstring). I've adopted the old MS method of conditional compiling: namespace ...
0
votes
1answer
83 views

How to fit a gaussian curve to data for a goodness-of-fit C++?

I've given a dataset of N samples like: (x,y) (-100,1), (-90, 30), (-50,60), (-10,90), (0,100), (10, 90), (30, 20),(100,4) Now I would like to determine how well the data fits a perfect gaussian (...
1
vote
1answer
63 views

How can I filter my coordinates system?

Following up with this, I have a bunch of coordinates and I draw them on a bitmap image as a coordinate system. Now, I would like to get rid of all the noise, and filter coordinates to give a "clearer"...
0
votes
1answer
69 views

Are there system calls like posix in assembly level using int number for windows

I want to write assembly program using windows syscall Interrupt number , so in order to use system call in assembly level using int of sys call, In windows are there kernel calls like posix ...
-2
votes
0answers
58 views

Do I need a commercial license for Qt if I'm going to sell on the Mac App store?

I would like to build an os x app and sell it on the Mac App Store. I'm going to build this in C++ and use the Qt library. I'm wondering if I can use the free version or if I need a commercial license....
3
votes
5answers
935 views

How does bitwise information storage in (32-bit) int variables work?

In this book I'm reading I'm going over bitwise operators. Its says the following in the book. Bitwise operations can potentially store a lot of information in a small amount of memory. Many ...
0
votes
2answers
67 views

Getting a stateless time-based index out of overflowing timer

I'm currently working on an Arduino project where I need to keep track of entries for a certain amount of time, in this case, 30 days. Our company will attempt to sell this product to cities and ...
1
vote
2answers
187 views

Design classes to prevent future code breaks

I'd like to design a robust version of this class (C++11): class Oscillator { private: std::vector<double> trajectory_; // Some numbers that are needed to get the trajectory ...
-2
votes
0answers
41 views

Compile projects on vs2013 [closed]

I'm learning C++, so I apologize for my lack of skills. I'm trying to use open source projects but I got stuck when compiling them on Visual Studio 2013. I'm a little confusing because in some ...
1
vote
6answers
203 views

Short circuit evaluation is C++? [duplicate]

I've been reading the C++ for dummies book and I'm loving it! I'm on the section where he is talking about short circuit evaluation. Here is my understanding of short circuit evaluation. Short ...
2
votes
5answers
430 views

Why isn't byte | bit the only built in data type?

All languages I have seen so far have multiple builtin data types (int, double, float, char, long...). But if we look closely, they are just arbitrary arrays of bits, the only difference between them ...
1
vote
3answers
125 views

Unlike C++, why does uncaught exception in JavaScript not terminate the script?

As someone used to C++ and new to JavaScript, I find this behavior odd. Whether a program runs directly on the platform like C++ ones, or it runs at a higher (or deeper?) level like JavaScript ones, ...
-3
votes
0answers
36 views

Sample embedded projects with unit tests written [closed]

I have a question related to the following post: best practice when unit testing for embedded development I am looking for some sample projects (may be on github) that have unit tests enabled. See ...
-2
votes
1answer
89 views

C++ Loop object “pairs” with one in common

I could not think of a better name. I have a class called MoveObjects which holds position and move info. Then I have two classes, Items and Attacks. Both have MoveObjects in common. What I am ...
-1
votes
3answers
135 views

What is the difference between this->data, and directly just data?

In C++ Is using this->data slower than data ?
-4
votes
0answers
88 views

High performance Inter Process Communication (IPC)?

Apologies if this question is "off-topic", I hope it's not... I'm looking for an IPC technology that is capable of communicating to processes on other machines, as well as on the same machine, with ...
0
votes
3answers
130 views

Is there a compiler switch changing the scope of variables in loops? [closed]

I'm using some code, which uses variables declared in a loop after the loop. For example for (int i = 0; i != 10; i++) { // do stuff } int x = i; I get the "i" undefined error. Is there a ...
1
vote
4answers
362 views

Why does C++ have auto, rather than simply doing the right thing when there are no explicit type declarations?

When auto was considered for addition to the C++ standard, was there any discussion of setting implicit types where there are no explicit declarations? And if so, was the discussion recorded anywhere?...
-1
votes
0answers
19 views

Faster determinant from LU decomposition of a matrix represented as 1D array?

I have this working algorithm to find the LU decomposition in place of a matrix (Stored as a 1xN*N array), and it works well, however I'm curious if anyone knows a way to quickly get the diagonal ...
3
votes
1answer
84 views

Regarding the Organization of Bit Shifting Utility Functions in C++

I am developing a project in C++ that deals with converting an ASCII hexadecimal string representation into binary. The class also has utilities in it for extracting info from the string. Right now ...
6
votes
3answers
553 views

How to properly deal with starvation

I'm trying to find a way to avoid starvation in my program, a producer/consumer (two threads, one for each role) problem with four priority levels (four deques). Basically, the consumer thread always ...
0
votes
1answer
115 views

Getting an array index (0,1,2,..8) from bit masking value (1,2,4,8..256) without using log2(n). Maybe a design issue

I'm working on a component where I put in data and I get different data as a result. The input is always the same (3 Objects). From these 3 Objects up to 9 other Objects can be calculated. One ...
0
votes
1answer
100 views

Inject several objects in C++ ctor

I'm looking for a good way to somehow dynamically inject several objects to main class and adjust its method by calls of these dependencies, e.g. ComponentClass1 { updateSmth1(); }; ...
1
vote
1answer
266 views

Using a domain name as C++ namespace

What would be a good system to use domain names as C++ namespaces in order to avoid name clashes between developers? The idea appears to be popular in the Java world. We cannot use namespace example....
0
votes
1answer
100 views

passing by refernce

I am study c++ and c languages, i was writing in javascript before. Im trying to understand the ideas of pointer and refernces. So im stuck with following, what would be the specific behaviour in this ...
12
votes
6answers
516 views

Idiomatic usage of exceptions in C++

The isocpp.org exception FAQ states Do not use throw to indicate a coding error in usage of a function. Use assert or other mechanism to either send the process into a debugger or to crash the ...
3
votes
1answer
63 views

Pitch/Time Shifting of a PCM byte array

I am searching for a universal algorithm that shifts pitch and time while keeping the sample rate. (I am trying to program a sound generator (sine, triangle...) as an exercise) I just want to squeeze ...
0
votes
1answer
57 views

Dynamically create some types of array and return that array as a collection of arrays

As an example, I have database select query that returns n columns and I didn't know how many rows return (lets call x number of rows return). Sample code (c++ and SQLite): while (sqlite3_step(res) =...
6
votes
4answers
374 views

How can I effectively use one file per class in C++?

Even though I have a decent bit of professional experience with object oriented programming in Java and a basic familiarity with C, I've run into a bit of a mental block with C++ that I was hoping ...
2
votes
2answers
139 views

C++ Snake Game Fruit: Change Coordinates or Spawn New Object?

I've decided to lean SDL and make a Snake game. I have gotten to coding the spawning of a fruit, which the snake eats to get longer. Every time the snake eats the fruit, the fruit needs to change to a ...
-1
votes
2answers
160 views

Is main() function better on top of all other functions? [closed]

My college professor told me that main functions should be defined on top of other function definitions. We should use a forward declaration in order to accomplish this (we use C at that time). So yes,...
0
votes
0answers
48 views

Linked list pop_back implementation ignores pointer-to-nullptr [migrated]

Let's assume I'm only allowed to use new and delete and no smart pointers in my implementation. I am not using sentinel nodes. Below is my implementation for pop_back: void sLinkedList::pop_back() { ...
0
votes
1answer
97 views

Syncing data from memory process (C++) to database

I have a C++ program that read game data from memory process. For example, int points = 0; while (1) { points = ReadProcessMemory(..) // points will be read from game's memory Sleep(100) // Don't ...
7
votes
1answer
242 views

Can the C++ template system be used to perform type safe operations of the relational algebra

Assume that the parameters of functions representing operations of the relational algebra are represented by individual types: structs or classes. An operation such as (natural) join will have ...
1
vote
1answer
83 views

Inner and outer class relationship: should outer class be friend of inner's?

Is this design bad? Does it break encapsulation? The structure class B is a component of class A. Therefore, class A needs access to class B's members. Let a house be class A. Let a housekeeper be a ...
0
votes
2answers
169 views

IF statement with OR logical operator

Just a basic question on IF statements in programming languages, specifically C++. Consider the following basic code example: int i = 2; if(i == 2 || i == 4) { //do something } Because the ...
6
votes
5answers
417 views

If A has B and B holds reference of A, is it a flawed design need to be fixed? [duplicate]

Suppose, I have class Boss and Worker; Boss has a Worker and Worker holds a reference of Boss: Boss.h #include "Worker.h" class Boss{ public: Worker worker; }; Worker.h class Boss; class ...
1
vote
1answer
135 views

What are the significant memory management models aside from Java (GC) and C++ (manual approach)? [closed]

There are at least two distinct memory management models: Java (we do it for you) C++ (it is your responsibility) I have two questions: (1) Is GC language specific or compiler specific? (2) Do ...
5
votes
1answer
94 views

Do I need to declare a delay timer variable as volatile even if I access it from another module

This is a question more about using volatile to prevent optimization than about caching write/read of a variable. Particularly timer delay variables since I don't want to declare everything volatile ...
2
votes
0answers
28 views

Zeromq bidirectional asynchronous transmission?

I have a system which consists of two applications. Currently, two applications communicate using multiple zeromq publish/subscribe sockets generated for each specific type of transmission. Sockets ...
10
votes
5answers
928 views

Techniques for ensuring cross-platform compatibility (C++)?

I was finishing one of my earliest C++ projects which is (according to the framework) supposed to be cross-platform. I developed the project fully in Windows and Visual Studio, thinking that since the ...
2
votes
1answer
69 views

Strategy for Binary File Format Description to C++ Implementation

I am dealing with a lot of legacy, reverse engineered binary file formats, often with lost source code and reading/writing these files needs to be recoded in C++. I am wondering if there are good ...
0
votes
3answers
290 views

If of loops or loop with if

Assuming the compiler is smart enough to only evaluate the if in the second example once, which version should one (semantically) use and why? if (b) { for (auto a : as) { foo(a); } } else { ...
1
vote
0answers
59 views

Pointers on porting a c++ workflow domain specific language to javascript

I am writing a game in c++ with the v8 javascript engine embedded in it. I have a c++ workflow system I use to tell things how to do specific things. It's nice and I like it, but I need it to work ...
2
votes
1answer
100 views

Writing a non-monolithic database wrapper

I have a SQL database to which I store and from which I read several objects into my C++ code. I wrote a single database wrapper which handles all the reads and writes to the DB. Of course this ...
-1
votes
1answer
143 views

How to signal a loop to continue the execution instead of using sleep

I am trying to create a thread that will sit and wait to detect new objects in a vector (the queue). Using a loop will crush the resources on the given machine, so I am trying to figure out how I can ...
-5
votes
1answer
242 views

Why code in C instead of C++ [closed]

Why code in C? Isn't C++ basically C but with better features? Why do people still use C? Would it be easier to make a game with C or C++?