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

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 ...
5
votes
2answers
1k views

Performance and other issues with using floating point types in C++

Being interested in C++ performance programming there is one aspect I really have no clue about- and that is the implications of using floating point calculations vs doubles vs normal integer ...
-1
votes
0answers
24 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
123 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 ...
0
votes
1answer
359 views

Interface questions for using Command Pattern and Dependency Injection together

I have many projects that have essentially the same high level requirement: test all hardware on a device. Each device can have a different communication protocol, requires different test equipment to ...
-4
votes
0answers
40 views

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

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 ...
-2
votes
0answers
26 views

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

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 ...
-3
votes
0answers
28 views

Class evaluate and linker error [on hold]

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
38 views

How To Make A GUI In C++ [on hold]

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
18 views

std::memory_order_relaxed modification order consistency [on hold]

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
39 views

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

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 ...
0
votes
1answer
231 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 ...
2
votes
2answers
462 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
59 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 - ...
0
votes
1answer
105 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
1answer
273 views

Creating a custom GUI. App/DE/WM?

I am starting with this project of mine of writing a custom UI for linux. What would happen is: The computer would boot into this UI which would not be the typical taskbar/icons/startbutton kind of ...
-2
votes
1answer
84 views

C++: Creating a budget program [closed]

I've just finished a basic C++ course which has covered everything from variables, structs and functions up to classes, objects and arrays. We've done a bunch of assignments in school, but I want to ...
7
votes
0answers
101 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 ...
5
votes
2answers
8k views

How to run C++ code in browser using asm.js?

An asm.js application is very fast (near native C++ speed): http://kripken.github.io/mloc_emscripten_talk/micro4b.png But how is it possible to write one in C++, convert it to LLVM code, then do ...
-6
votes
0answers
65 views

Write a program that lets the user enter 10 values into an array. The program should then display the smallest values stored in the array [closed]

On line 32, the compiler says that it expects something before the "]". What am I doing wrong? :( # include <iostream> using namespace std; int smallest (int arr[], int ARRAY_SIZE); int ...
-4
votes
0answers
35 views

How to make this header and function work, for game “connectfour” [closed]

#define MAX_ROWS 6 #define MAX_COLS 7 typedef enum color { YELLOW, RED } Color; typedef enum boolean { FALSE, TRUE } Boolean; typedef struct cell { int row; int col; Color ...
11
votes
5answers
299 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 ...
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 ...
2
votes
2answers
251 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
77 views

saving connectivity information in a nodes/edges network

I want to implement the A* algorithm. I have a network with Nodes and Edges, both are classes. Now, I am unsure how to approach the connectivity information. Should a node know which edges depart ...
2
votes
1answer
63 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
92 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. ...
1
vote
1answer
75 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
305 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 ...
0
votes
1answer
97 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 ...
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 ...
3
votes
3answers
484 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
vote
3answers
262 views

How to manage focus for a small set of simple widgets

I'm developing a set of simple widgets for a small (128x128) display. For example I'd like to have a main screen with an overlay menu which I can use to toggle visibilty of main screen elements. Each ...
10
votes
6answers
17k views

Why are constructors not inherited?

I am confused as to what the problems could be if a constructor was inherited from a base class. Cpp Primer Plus says, Constructors are different from other class methods in that they create ...
55
votes
17answers
6k views

What programming problems are best solved by using pointers?

Well, I basically understand how to use pointers, but not how best to use them in order to do better programming. What are good projects or problems to resolve involving the use of pointers so I can ...
15
votes
6answers
1k views

Is it a good habit to use C expressions in C++ code?

At school we started learning C this year, despite the fact I'm way ahead of class, and I learned Java, C++ and C while the class is at the base of C. Anyhow, I've been documenting myself, reading ...
-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. ...
17
votes
3answers
3k views

How to solve the problem of nested comments

It appears in not just one language that comments can't be nested. Do you have a good solution for this problem? One workaround in C/C++ and Java is to only use the single-line comment but it becomes ...
12
votes
1answer
316 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 ...
3
votes
2answers
236 views

Decision making and maintenance

I'm trying to find an elegant way to implement a decision making algorithm that allow easy maintenance because the conditions for the decision making might change often. I'm going to try and be more ...
6
votes
3answers
468 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
636 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
4answers
305 views

Organise C++ classes around SQL database

My question is about how best to organize C++ classes around a database model, and I understand this may appear very elementary. The software I propose to create will do the following. It is intended ...
-1
votes
3answers
133 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++?" ...
-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 ...
0
votes
1answer
233 views

GUI code implementation for specific Window/Form class

Terminology Element/Form Element -> Fields such as text list, combo_boxes, push buttons, etc. Problem I have a program that is basically a fat client that interfaces into a system that keeps track ...
3
votes
5answers
1k views

What is “using namespace” pollution?

I was looking at the google coding guide [here] and they do not recommend that one use the using namespace ornamespace:function` - if I did not misinterpret it. Does this apply to std as well? ...