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

learn more… | top users | synonyms

-1
votes
1answer
30 views

Unnamed member access?

I'm trying to understand this piece of C++ code from a text book: template<typename T, int N> struct Buffer { using value_type = T; constexpr int size() { return N; } T[N]; // ... }; ...
0
votes
1answer
32 views

C++ How Template Parameter Packs Work Internally

I have a general understanding of template parameters work, but I want to know how they work. Are they like an array of typenames? If you have: template<typename... Ar> void f(const Ar&... ...
0
votes
2answers
48 views

What exactly is interface compliance in C++?

I was reading this. It says that Some people believe that the purpose of inheritance is code reuse. In C++, this is wrong. Stated plainly, “inheritance is not for code reuse.” The purpose ...
-5
votes
0answers
18 views

Making a C++ desktop application (without framework), where to start? [on hold]

I am a PHP programmer with some experience in C++ (console applications only, uh). I haven't touched C++ in over a year now, but I would like to get back to it and create my own C++ desktop ...
2
votes
3answers
395 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 ...
8
votes
1answer
239 views

C++ serialization design review

I am writing a C++ application. Most applications read and write data citation needed and this one is no exception. I created a high level design for the data model and serialization logic. This ...
-3
votes
0answers
49 views

How to read a file in C++? [on hold]

I wanted to know how I could read a file called box.3d in a file on my desktop called objects in C++. I've looked and couldn't find anything that works for me. Also how could I make a function where ...
-5
votes
0answers
27 views

How to play sound in C++ using android C++ compiler? [on hold]

I want to play sound (mp3) in C++ using C4droid. I searched on web, but I can't use "Window.h" library. Is there any way to play sound in C++ using a Android C++ compiler?
-6
votes
0answers
12 views

CPP | std stream printing error [migrated]

I am currently programming an int matrix in cpp. I wanted to add a printing function that prints the numbers in the following way: 1 2 3 7 6 9 19 23 9 (every 2 intergers are seperated with a ...
28
votes
13answers
4k views

Tutoring students who are struggling with the basics in C++ [closed]

I am tutoring a few students who are having significant trouble learning the basics of their first programming language: C++. I have known many excellent and bright students who have failed or dropped ...
1
vote
1answer
96 views

C++ Runtime and runtime-linking

I was installing boost and I came across an option named "runtime-link". After searching a bit, I came across yet another complex topic: "runtime system" that according to Wikipedia: The runtime ...
-2
votes
0answers
39 views

Free all surfaces in SDL? [migrated]

So I have a bunch of SDL_Surface*'s in a C++ program. I want the program to free all SDL_Surface*'s when the program closes by default but I can't find a function to do it. I'm currently using an ...
3
votes
4answers
2k views

C++ log every function and parameter values [on hold]

I want to log every function call and parameter value in my C++ app. Is there a generic approach for this task ? (3rd part library, VAR_ARGS etc.)
1
vote
0answers
103 views

Integrate C++ DLL with C# GUI asynchronously (design issue)

This is more a design than an implementation question. I am aware of how to integrate a C++ DLL within a C# main app that acts as GUI. Believe me that I've read all other questions on similar topics, ...
-2
votes
0answers
51 views

What's the lhs/rhs equivlent of a single parameter? [on hold]

Typical operator overloading conventions go like this: MyObject operator+(const MyObject& lhs, const MyObject& rhs) { return MyObject(lhs.my_value + rhs.my_value); } What would be the ...
0
votes
2answers
656 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 ...
32
votes
13answers
38k views

Why is C++ still preferred to build heavy GUI apps over the latest dynamic languages? [closed]

I see that most of the apps that include heavy GUI content are usually developed in C++. Most of the games/browsers are coded in C++. Can't we just develop better GUI apps with the latest dynamic ...
0
votes
1answer
134 views

What is the difference between “Wide character” set and “Unicode character set”? [on hold]

Today I was reading my favourite C++ Programming book (C++ Primer Plus) and the section which was about variables and character sets in C++, however I got really confused about Unicode and Wide ...
4
votes
3answers
704 views

Const means Thread-safe? [on hold]

I was put onto this video: http://channel9.msdn.com/posts/C-and-Beyond-2012-Herb-Sutter-You-dont-know-blank-and-blank By http://codereview.stackexchange.com/users/39810/glampert Because I asked ...
0
votes
0answers
66 views

How to achieve time localization in c++? [migrated]

I'm using the time_t and ctime header to get the time in my app, and it's all OK. The problem is that, the week days and months are displayed in English and i want them to be displayed in my language ...
3
votes
3answers
214 views

Polymorphic template container: shared_ptr vs reference_wrapper

Assuming we have two classes: class A { ... } class B : public A { ... } Would it be better to write std::deque<shared_ptr<A> > container; or ...
20
votes
10answers
7k views

Do we still have a case against the goto statement? [duplicate]

Possible Duplicate: Is it ever worthwhile using goto? In a recent article, Andrew Koenig writes: When asked why goto statements are harmful, most programmers will say something like ...
1
vote
1answer
82 views

When's a resource a resource?

So I have a rendering engine, and I have a resource manager that adds classes that derive from type 'Resource'. It's a very flexible and generic resource manager, of which only one can exist (it is a ...
0
votes
1answer
70 views

Deciding on a software license for a C++ API [closed]

I have designed and developed a C++ API. Its dependencies are: BLAS - custom license - http://www.netlib.org/blas/#_licensing LAPACK - modified BSD - http://www.netlib.org/lapack/LICENSE.txt GLPK - ...
2
votes
1answer
176 views

Refactoring a god Manager class

I am running in the exact problem Robert Martin mentioned when having a class named Manager, mine has too much (redudant) code. I am writing a system doing computations on many buffers containing ...
4
votes
5answers
672 views

Checking array size in C/C++ to avoid segmentation faults

So it's well known that C does not have any array bounds checking when accessing memory. Nowadays, if you call myArray[7] when you initialised it as int myArray[3], your program will get a segfault ...
0
votes
1answer
151 views

What is an efficient data structure for syntax highlighting in text editors?

I'm creating a very small text editor in C++ with the ncurses library. So far, it works great. I have implemented the Gap Buffer data structure to make the editing more efficient than a line-based ...
0
votes
0answers
48 views

Dll that uses services from its caller [closed]

I am making simulators with graphic engine based on c++. I decided to make a dll for shells/bullet shooting for the use of the simulators. The thing is that the dll need information of the terrain ...
20
votes
5answers
6k views

Is it a good idea to “#define me (*this)”?

This macro can be defined in some global header, or better, as a compiler command line parameter: #define me (*this) And some usage example: some_header.h: inline void Update() { /* ... */ } ...
4
votes
1answer
118 views

Genesis of C++ temporary object lifetime extension

I'm revising a proposal to expand the C++ feature where "temporary" objects cease to be temporary when attached to a name by binding a reference. Here's a sample of the classic behavior (not the ...
0
votes
2answers
93 views

How to initialize an array of const char * strings and initialize each one of the strings contained within? [closed]

I'm trying to initialize an array of 50 strings, each one containing just a period. Here is what I am using: const char ** dotboard = new const char * [50]; That allocates memory for the string ...
4
votes
2answers
288 views

Can higher order functions ever be pure?

I was thinking about pure functions especially in the context of C++, which of course is not a purely functional language, and was wondering if higher order functions in C++ can ever be considered ...
-1
votes
0answers
9 views

send data socket TCP,ERRoR sendig: Bad file descriptor [migrated]

I want to create data and then send to server . data(information on each sensor) should create in Network.cppafter new sensor added( each sensor is an new network) and send with client.cpp ,I use ...
4
votes
1answer
59 views

Makefile for library project to be able to compile the unit tests and the demo program using make

I am new to makefiles and I am developing a (non-executable) library in C++. Additionally to the library I have (executable) unit tests and an (executable) demo program. I would now like to be able ...
2
votes
1answer
84 views

Multithreading with triple buffer, do I have to do the waiting for the condition variable?

I have a triple buffer implementation that is often used in threads in such a way that when new data is expected, there's always a WaitData(n) function called on the buffer (A condition variable's ...
3
votes
3answers
298 views

Possible alternatives to copy constructors

In my C++ project I am relying on some libraries that do memory management for me. I make wrapper classes, for ease of use and memory safety, for example the class below. Note that this is a much ...
2
votes
1answer
620 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 ...
5
votes
1answer
121 views

Directory organization of a CMake (C++) repository containing several projects

I would like some advises on the organization of a set of related but independent C++ projects stored in a single (git) repository. The projects use CMake. For a simplified example we imagine 2 ...
5
votes
0answers
107 views

Key / Value store development porting to modern C++

I am developing a database server similar to Cassandra. Development were started in C, but things became very complicated without classes. Currently I ported everything in C++11, but I am still ...
0
votes
0answers
34 views

Qt / C++ internal API design for slightly similar web services

in my application I provide a Qt/C++ wrapper to certain web services based on the Danbooru software. Basically the API wraps a series of REST calls and produces / parses the JSON responses to display ...
0
votes
0answers
61 views

What does the const keyword do in an operator definition? [migrated]

I don't understand what the const keyword is used for in front of the return type and after the parameter list of this operator definition. This is taken from an example from a book. const char& ...
1
vote
4answers
122 views

Better way of handling pre conditions and logging

1. Imagine you have the following: void Foo::doFoo() { if (!isConditionValid()) { log("doFoo not possible because condition is not valid"); return; } if ...
5
votes
3answers
1k views

Is it a common practice among professional programmers to avoid the use of raw pointers? [duplicate]

C++ tools and libraries have become more powerful than ever. For instance, we can replace arrays by vectors. We can replace pointers by references. We can use smart-pointers. Is it a common practice ...
0
votes
0answers
22 views

How can I automate updating code on an integrated device with files and a MySQL database?

I have an integrated device that has a program in it currently written in Node.js. So, naturally, there are a whole bunch of files that it needs to run. Also, there is a MySQL database that it uses ...
0
votes
1answer
108 views

Flat files for events and alarms

So I'm working on a project that I was introduced to a year ago. One of the features of project involves alarming the users when certain events are triggered. There is also a log of these events. ...
2
votes
3answers
233 views

How to share data members between classes in C++ without violating encapsulation too much

In C++ let's say I have some class A: Class A { int a1, a2, a3; void foo(); } and I need to use a subset of members (a1, a2) in a member function for a second class B. ...
6
votes
3answers
442 views

How to extract the active code path from a complex algorithm

I have been puzzled lately by an intruiging idea. I wonder if there is a (known) method to extract the executed source code from a large complex algorithm. I will try to elaborate this question: ...
2
votes
1answer
221 views

General design choices. How do you decide?

I have a project in C that I'm looking to convert to C++. The project does white box hardware testing of a device (actually many similar devices). In this case the device has two processors. Each ...
-2
votes
1answer
60 views

What's an effective threading structure for NIO and server performance in C/C++? [closed]

I run into this issue where if I do a read to check for data too often, my CPU skyrockets, and if I don't check often enough, it's slow for client performance. What's an effective way to deal with ...
16
votes
5answers
6k views

Using static classes as namespaces

I have seen other developers using static classes as namespaces public static class CategoryA { public class Item1 { public void DoSomething() { } } public class Item2 { ...