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

learn more… | top users | synonyms

-1
votes
0answers
8 views

how to solve error opening (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545?

I trying to connect visual studio 2010 and foscam IPcamera. After running the code it give me this error "warning: error opening (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545". Opencv2.411. Any ...
0
votes
6answers
1k views

Why languages that compile to C/C++ generate unreadable, cryptic code? [closed]

I'm willing to compile certain language to C or C++ for some speedups. My idea was, though, to generate readable code and use structures such std::vector and similar wherever I can, expecting CLANG to ...
1
vote
1answer
76 views

Will issues arise packaging libc and pthread with your C apps?

The issue I hit, is that I am packaging shared libraries with my code in order to load GNUTLS, except for libc, because I figured any system will have it. Most of them don't have the required 2.14 for ...
0
votes
0answers
82 views

Header files and additional libraries [migrated]

I am building a simple C++ software, which is basicly constituted by a main function and two nested classes. In each class and function I use strings and vectors - thus the softare requires additional ...
0
votes
0answers
43 views

Best way to implement signal/slots for application menu

I want to create a desktop application using Qt framework. The main application will have a menu bar and every menu many actions. In order to achieve this I've a MainApplication class, a MenuBar ...
0
votes
0answers
69 views

Can I use write a null value into a file? Turbo C++ [on hold]

OK So I've been trying to create a manual database in C++. I have a structure called node, which has all necessary datatypes. struct node { int x; char y[100]; float A; }; now, I want the user to ...
2
votes
0answers
41 views

Could Java import C++ classes from a library using JNA or JNI?

In past, I used JNI to access some winapi functions, however winapi is C and therefore just procedural. Now my plan is different and I need to know whether I'm going in the right direction. What I ...
2
votes
3answers
89 views

How to simplify structure of a monitoring software that uses the Observer pattern?

I am working on a project where I have to monitor the status of an elevator. So far, my design looks like this: We are using a third party library to read and monitor real-time values from the ...
35
votes
7answers
16k views

Why is there no 'finally' construct in C++?

Exception handling in C++ is limited to try/throw/catch. Unlike Object Pascal, Java, C# and Python, even in C++ 11, the finally construct has not been implemented. I have seen an awful lot of C++ ...
-2
votes
1answer
88 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
42 views

C++ How Template Parameter Packs Work Internally [on hold]

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
92 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 ...
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
258 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 ...
-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
100 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 [closed]

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
111 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? [closed]

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
658 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
138 views

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

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

Const means Thread-safe? [closed]

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
218 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
85 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
71 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
695 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
158 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 ...
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
122 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
98 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
291 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
60 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
86 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
306 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
623 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
130 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
115 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
36 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
125 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
23 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. ...