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

learn more… | top users | synonyms

-3
votes
0answers
29 views

C application vs C++ application [on hold]

What are a real life application that is based on C language rather than C++? Why is it using C and not C++ since they are almost the same? Do you think we can convert that application to C++? And how ...
-4
votes
0answers
17 views

Getting the Max Age of a student using Class C++

Please, help me and check my program:i want to use the maxAge() member function to get the student age (Maximum age) entered from the function MAIN using the while loops which i stored into the ...
-12
votes
0answers
99 views

Why are they still using C program [on hold]

Why are they still using C even though not OO (object oriented)?Are they using Windows or Unix Environment? If either, what are the advantages or disadvantages? What it takes to move from procedural ...
-3
votes
0answers
59 views

Material on advanced C++ features [on hold]

I'm an experienced C programmer currently working on learning C++. Since I'm mainly interested in its advanced features I was looking for the following. Is there any tutorial or similar out there that ...
2
votes
1answer
129 views

Most efficient/cleanest way to Kill a recursive thread safely

I have a number of worker threads which all perform a flood-fill task on different regions of a bitmap. They all make calls to a recursive sub-routine with different parameters(coordinates). Fyi, I am ...
2
votes
2answers
131 views

OpenGL vs OpenCV for beginner

I am a freshman college student currently learning C++ programming. I am good at math and physics, so I am looking to specialize in 2D/3D graphics with OpenGL. My question is about the differences ...
1
vote
0answers
123 views

How to Keep Track of Thread Safe Code in a mostly Thread Unsafe Legacy Rich C++ Code Base

For large legacy C++ code bases, notions like Herb Sutter's "const means threadsafe" don't seem to help much, because there can be an overwhelming amount of code in const functions which are modifying ...
-3
votes
0answers
40 views

Input data type conflict causing infinite loop [on hold]

The code below shows a simple program, which is a small piece of code from simple math game.But in the add() function...if we cin a data type other than an int..the console displays Try again ...
-1
votes
0answers
32 views

install tesseract on visual studio 2012 [on hold]

I am trying to use Tesseract and I followed the instructions that appear in the following link http://blog.ayoungprogrammer.com/2012/11/tutorial-installing-tesseract-ocr-30202.html (with minor changes ...
6
votes
3answers
129 views

Passing parameters that need to be copied by value or const reference

I have a basic (mathematical) vector class, which in my opinion benefits from C++'s operator overloading. Vector-scalar operations are defined as self-modifying functions in the class itself, class ...
-2
votes
0answers
31 views

A library to be able to reproduce mp3 files in Raspberry Pi [closed]

I've been having a hard time looking for a simple library to reproduce audio files (mp3 precisely) , i've tried pyglet for python, but didn't succeed, but look, the only thing i want/need is a library ...
-4
votes
0answers
42 views

How to print The sequence of numbers in structure array [closed]

I have the task which cannot be solved. My task is create a sequences of cards. How print my sequences ? i really need help. my solution #include <iostream> #include <fstream> #include ...
-4
votes
0answers
50 views

expected primary expression before 'bool' [migrated]

My program says "error: expected primary-expression before 'bool'" on the function call repeatOrNot (bool); under the main function. Why is this? bool fiveOrNot(); void repeatOrNot (bool); int ...
-3
votes
0answers
33 views

Class evaluate and linker error [closed]

I wrote class evaluate to compute the answer of postfix notation.Actually want to convert infix to postfix (like 2*3+5 to 23*5+).i used shunting yard alghorithm but when i compile my code i got this ...
-4
votes
0answers
44 views

How To Make A GUI In C++ [closed]

So, I have seen many programs (Microsoft Office, Google Chrome, etc) become predominantly coded in C++. So, I planned to started learning. I've gotten to the level of GUI, and there doesn't seem to ...
-2
votes
0answers
21 views

std::memory_order_relaxed modification order consistency [closed]

from http://en.cppreference.com : Relaxed ordering Atomic operations tagged std::memory_order_relaxed are not synchronization operations, they do not order memory. They only guarantee atomicity and ...
-2
votes
0answers
44 views

What are the Steps/Algorithm to load/Parse an XML File? [closed]

I want to write an xml parser by my own, its a project given to me, and i should complete it, i know to search for a string, load files into memory using vectors, but is theres a way i can use this to ...
2
votes
2answers
477 views

Isn't there a chicken-and-egg issue since GCC is written in C++ itself?

Since 4.8 release, the C++ compiler GCC (the G++ part of it) is written not in C anymore, but in C++ itself. I have a hypothetical question on this. I wonder how to compile the C++ code of GCC on a ...
0
votes
0answers
60 views

Design of a datamodel in a OO way

I'm looking for some advice how to design a datamodel in OO way (C++ in special). My problem: The user input in runtime is a 1D matrix A = (a0,...,an). The program creates - on the basis of A - ...
7
votes
0answers
110 views

Message Queue for RTOS for microcontrollers

I'm currently writing an RTOS for microcontrollers. The whole thing is written in C++11 - if anyone is interested, and the link to the repository is at the bottom. Currently I'm writing a class that ...
0
votes
1answer
106 views

Introducing function waypoints to protect device [closed]

Defining a magic pointer or counter inside a program / class and checking for a fixed value before executing critical commands is a way to generate a barrier against wrong execution. This check is ...
0
votes
0answers
5 views

How to use the modulus when clearing an array? [migrated]

I have a method that clears the multidimensional array. Instead of two for loops, I'm using one for O(n). In doing so, I have to check if it reached the width of the array each time in each row. I'm ...
11
votes
5answers
308 views

Allow iteration of an internal vector without leaking the implementation

I have a class that represents a list of people. class AddressBook { public: AddressBook(); private: std::vector<People> people; } I want to allow clients to iterate over the vector of ...
2
votes
1answer
66 views

Enforcing manual inclusion of a specific header file (banned.h)

Banned.h is a list of ANSI C functions that Microsoft is trying to persuade programmers to deprecate. I already know how to enforce automatic inclusion of banned.h (such as the answer to Ensuring that ...
2
votes
1answer
93 views

Use cases and usage patterns of futures vs callbacks

I've become interested in futures lately, mostly due to their inclusion in standard C++ - but I see there is an active debate over futures vs. callbacks in many programming areas, such as Node.js. ...
2
votes
2answers
252 views

Early destruction of objects in c++

I am not sure if this is the right forum of this question, but I will try here since this question about the c++ language. The problem: I use one global variable in my code which is a graphics ...
1
vote
1answer
76 views

Which design pattern restricts limits class creation to certain classes

I have a fairly simple application that is divided into two classes. The first class is the Manager class and the second class is the employee class. These are simple classes and do not inherit from ...
-4
votes
0answers
18 views

Separate two inputs C++ [migrated]

I have made a quiz helper, but, as I want it for you to be able to input a new question without starting it, I made a do/while loop. The first run goes fine. When it asks you if you want to input ...
0
votes
3answers
314 views

What can C++ do that Python cannot? [closed]

I was reading this post: http://www.quora.com/What-are-the-advantages-of-Python-over-C++ And I am wondering the converse of this question: what can C++ do that Python cannot? For example, in the ...
2
votes
2answers
93 views

Preferred way of handling errors when loading an object from a file

If I want to load an object from a file, there are a number of things that can go wrong. Thus, one needs a way of handling errors when doing so. In some languages, like haskell, one can return a Maybe ...
0
votes
1answer
98 views

Intermediate results as variables or only base values?

I have a object which has a few base variables (integers as example) and one intermediate variable for further processing. The intermediate variable can be calculated from the base vars. Now the ...
-1
votes
0answers
41 views

Unexpected value using random number generator as a function in C++ [migrated]

C++ beginner here with a problem using a functions. Please help! I am trying to make a random number generator function that I can call from within int main to cout a randomly generated float between ...
2
votes
1answer
96 views

Unique_ptr to hold memory for custom VM

I work for a company that use a custom DSL and my job is to port the VM to C++. I'm trying to do this in compliance with the C++11 standard so i use auto when appropriate, the new for syntax, etc. ...
12
votes
1answer
318 views

What is the point of making a syntactic distinction between standard and user-defined types?

Although here I will refer specifically to C++ and Bjarne Stroustrup's naming conventions, in principle, I've seen that people use somewhat similar rules for other languages here and there. So, the ...
-2
votes
0answers
27 views

How do you write to a second console? (C++) [migrated]

I had the idea of using a second console in my programs for the purpose of logging programming activity. I looked around on msdn for related functions/examples and tried to put together a simple ...
3
votes
3answers
485 views

Should an object load itself?

although I'm programming in C++ for some time now, I'm always faced with design decisions (probably due to the language's flexibility). One such problem is deciding if a method should be part of the ...
-1
votes
3answers
136 views

Objects in smalltalk and c++ [closed]

I have a question based on SmallTalk and C++. In one of the programming languages books, there is a question like: "Does an object in Smalltalk require its own private stack? What about in C++?" ...
7
votes
3answers
476 views

How to prevent others from using non-thread safe variables in a multithreading environment?

I have an application written in C++ that was originally single threaded, but, due to the increasing complexity of this project, I'll need to expand it to at least two or three threads. There are ...
-2
votes
4answers
649 views

Determining the winning condition for Tic-Tac-Toe [closed]

I'm writing a tic-tac-toe game in C++ and now I found a function to check if a player has a winning board for a connect four game. The function looks like this: bool haswon(int64_t board) { ...
3
votes
2answers
2k views

Every function is a closure?

Wikipedia says, that closure - is a function, which has an access to variables, declared outside of the function. There is even an example: function startAt(x) function incrementBy(y) ...
1
vote
4answers
712 views

try/catch open/closed principle violation

I have three or more different custom exceptions that a class can throw and I need to use try/catch in order to discover which exception was thrown. In my point of view this piece of code violates ...
38
votes
9answers
7k views

What did people do before templates in C++? [duplicate]

I am not new to programming, but I am one that started a few years ago, and I do love templates. But in the before times, how did people deal with situations where they needed compile-time code ...
0
votes
3answers
256 views

Using PHP or C++ for in real world electronic devices

I want to use my programing skills to make my day-to-day life easier, to do this I want to be able to program in my appliances like alarm clock or microwave or refrigerator, air conditioner etc, wish ...
3
votes
3answers
319 views

Should we add constructors to structs

We often use c++ structs to define data structure as opposed to class which can be a complete module with member methods. Now deep down, we know they both are the same (loosely speaking). The fact ...
0
votes
1answer
232 views

Is factory pattern a right pattern for the situation described here?

Is factory pattern a right pattern when we want to consolidate the related objects? Problem - In the Set-top box, I have a user-io, basically the interface to control the settop box - The user-io can ...
0
votes
5answers
219 views

Race conditions in JVM languages versus C/C++

I was thinking about thread synchronization issues in compiled languages like C++, versus synchronization issues in languages like Java. I'm wondering how a JVM language like Java doesn't (at least ...
7
votes
5answers
730 views

Coding style issue: Should we have functions which take a parameter, modify it, and then RETURN that parameter?

I'm having a bit of a debate with my friend over whether these two practices are merely two sides of the same coin, or whether one is genuinely better. We have a function which takes a parameter, ...
3
votes
2answers
233 views

What's wrong with statically linking the STL into multiple shared libraries?

Here is the scenario: libA.so and libB.so both statically link to the same STL. libA.so has a public API that returns a std::string. libB.so calls this function and receives a copy of the string. ...
1
vote
3answers
233 views

Including extra headers that I do not really need

I always wondered what are the effects of including not needed headers to the final executable once compiled. In my code some times I may included many different headers that I do not need (or I used ...
3
votes
2answers
114 views

OOP CLI menu structure organization?

This problem has kept me from pursuing a project I'm working on because it influences the entire structure of the application. This question has been briefly touched on here, but I feel that it wasn't ...