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

learn more… | top users | synonyms

-6
votes
0answers
17 views

User-friendly xml parsing libarary for c/c++ application supporting default values [on hold]

I am looking for user friendly library for parsing an xml file. Minimal requirement is I should be able to get default value of attribute if it is not present, with support to extract c++ data types ...
1
vote
1answer
60 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
37 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
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
62 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
39 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
88 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 ...
-2
votes
1answer
85 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
89 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 ...
-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 ...
-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 ...
-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 ...
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, ...
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 ...
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 ...
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 ...
8
votes
1answer
256 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 ...
1
vote
1answer
84 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
690 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
157 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 ...
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
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
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
305 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 ...
5
votes
0answers
114 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
35 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& ...
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 ...
-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 ...
-5
votes
0answers
40 views

C++ - how is it with real numbers? [migrated]

int main() { float fNumber = 1234567.89; cout << (fNumber + 1) - fNumber << endl; cout << (fNumber - fNumber) + 1 << endl; } results: 0 1 Can anyone explain ...
-3
votes
0answers
35 views

How to define member function in separate source file? [migrated]

Consider following two programs. p1.cpp #include <iostream> struct test { void fun(); }; int main() { test t; t.fun(); } p2.cpp #include <iostream> void test::fun() { ...
2
votes
3answers
234 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. ...
2
votes
1answer
105 views

Template Function: Passing Iterators

I am struggling with making a design choice in the following setup: I am writing (C++) functions which take a pair of iterators (to template containers) and compute a return value of the same type ...
1
vote
4answers
124 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 ...
-2
votes
2answers
141 views

Is it ever overkill creating classes/objects? [duplicate]

I just learned how to create a class or object in C++ and I'm practicing and learning. I'm writing a text based version of a popular board game and I was wondering if it's overkill creating a class ...
1
vote
1answer
48 views

Qt/QML/C++ Application database connection object visibility

I am working on some Qt/QML/C++ app and I've got myself into some kind of dead end. Namely, this app uses mysql database and here is my questions: Is performance hurt if I instantate new database ...
4
votes
0answers
64 views

Strategy for OS X and downlevel version of C++11 library?

I think I've found myself in a situation where things are quickly spiraling out of control, and I'd like to get some feedback to select a way to proceed. BACKGROUND I'm working with a library based ...
4
votes
0answers
87 views

What is the correct place to put checking of conditions in this use case?

Here is the situation: I have a database and a class that is basically a representation of a set of fields of different tables in it. Let's call it Message. "Message" does not know of the database ...
3
votes
2answers
133 views

Are string characters assigned a numerical value in context of how they are assigned in a programming language?

For context I am fairly new to programming after returning back to it after programming a number of years ago... I was reading Bjarne's intro programming with C++ and was wondering if alphabetical ...
0
votes
3answers
119 views

A secondary “type system” for references?

I'm designing a language and was wondering how to incorporate C++-like references with regards to their place in the type system. I think they're useful for operations like indexing and dereferencing ...
3
votes
4answers
202 views

Design: Lisp (or other scripting language) as an interactive interface for C++?

I'm working on a medium size C++ project (will probably end up around 50k lines) and I have to provide an interactive terminal interface. The program produces scientific data as an output and the ...
1
vote
1answer
83 views

How to handle design changes for auto_ptr deprecation in C++11?

We are testing a library under C++11 (i.e., -std=c++11). The library uses auto_ptr and this pattern: Foo* GetFoo() { autoptr<Foo> ptr(new Foo); // Initialize Foo ...
1
vote
1answer
157 views

What would be a reason not to embed JS in C? [closed]

I'm working on an opensource application that processes JSON in C, because I would like to make it easier for people to help me in the project and because JSON is so close to JS. I want to embed a JS ...