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

learn more… | top users | synonyms

11
votes
4answers
704 views

What are the problems of bringing C++-like const into a language?

I am interested in the idea of C++-like const not that particular execution (like casting away const). Take for example C# -- it lacks C++-like const, and the reason for it is the the usual -- people ...
54
votes
11answers
9k views

A modern review of Java [closed]

I've been programming for a few years and I began in Java, and in my time I've found many different sources claiming Java to be an inferior language in some way or another. I'm well aware that each ...
1
vote
0answers
220 views

Binary Tree/Knowledge Base design C++

Currently I have a binary tree template setup where my main is using it with strings to make a question/answer game. I'm using a knowledge base that works as an interface to the binary tree that main ...
1
vote
4answers
220 views

Learning programming from a book which uses C++98 [closed]

I am learning programming from a book called "Programming Principles and Practice" by Bjarne Stroustrup. It has been highly recommended over here and elsewhere. My only issue is that it uses C++98 and ...
-1
votes
2answers
558 views

C#/C++ GUI development without drag and drop? [closed]

I'm currently programming Java, I have played around with C++ before, but I have never touched GUI as I feel "cheat-like" when using its drag and drop system. I feel good and enjoy programming my own ...
1
vote
1answer
171 views

gtkmm manage/add vs smart pointers:

gtkmm provides lifetime management of widgets using Gtk::Widget* aWidget = Gtk::manage(new Widget()); Gtk::Widget.add(*aWidget); This delegates lifetime management of aWidget to its container ...
0
votes
2answers
230 views

Shared source file between two parts of project [closed]

I have the following sort of directory structure: part1 build src part2 build src Now I have a header file that I would like to include in both parts of these projects, it will ...
1
vote
2answers
180 views

Large number of projects for a single application

I'm working on 300K line C/C++ Windows application that is spread across 23 different Eclipse projects (approximately one third for Qt interface, one third for DLLs and one third for static ...
3
votes
2answers
257 views

Speed difference between VM-based and compiled code [closed]

Not so long ago I was told by a senior academic that, these days, VM-based code could run nearly as fast as compiled code, but my own experience is that compiled code runs several orders of time ...
0
votes
2answers
334 views

How do programs like JAVA and C++ store variables in a database , does it still use MySQL like in PHP? [closed]

I imagine they have to have some sort of query to goes to a database , or maybe I'm wrong and they can just store it to their computer? Is MySQL for server - side scripting only?
5
votes
3answers
453 views

Member functions vs. Non-member functions for math operators

I'm writing a linear algebra library (long story short, it's a school assignment) that involves matrices, vectors, etc. In the process of creating this library, I'm going to be creating functions ...
7
votes
4answers
707 views

Apple eating problem

Player A and Player B play a game. On the middle of the table there is a pot full of N apples of different weights. Player A starts first and choose an apple and start eating it. Losing no time player ...
1
vote
2answers
2k views

Is rewriting some Java code to C++ using JNI to improve performance a good idea? [closed]

I've tried rewriting some Java functions in C++ and called them using JNI. I observed that it takes longer time to execute the native C++ functions as compared to Java functions, due to the JNI ...
0
votes
2answers
164 views

In C++ what is the commonly accepted method for making a program platform-agnostic? [closed]

The way I usually do it is I make some namespace Platform in Platform.h and every OS call is encapsulated by a static function in this namespace. So the only place in the entire code base that knows ...
0
votes
2answers
110 views

Design principles : classifying different types of class [closed]

I'm trying to clarify the design of a C++ application, and would like to define a clear classification among classes to aid clarity. However I'm struggling to find any literature to help me, probably ...
1
vote
3answers
1k views

How to ensure that a member variable is initialized before calling a class method

There's a class with a parametrized constructor that initializes a member variable. All public methods of the class then use this member variable to do something. I want to ensure that the caller ...
31
votes
3answers
72k views

Android development using C and C++

I am a C, C++ developer. I am interested in mobile development. I want to know how can I develop Android apps using C and C++, I have read that they are providing a kit for C, C++ developers but it ...
1
vote
3answers
179 views

C++ project organization to reduce unit testing build time

I want to organize tests for a project large enough that build time matters (especially for the CI server). Say I have this code that I would like to test : //foo/greet.cpp #include <stdio.h> ...
28
votes
6answers
6k views

What does the latest “C++ Renaissance” mean? [closed]

There's recently some voice about C++ renaissance, among which the most noteworthy one is from Herb Sutter, Chairman of the C++ Standard Committee. You can search for "C++ renaissance" on Google and ...
0
votes
0answers
62 views

On the process of replacing an internal framework by a public one [duplicate]

I am working on several applications which depends on a framework which was developed by a prior engineer in the company. The framework was mainly developed and maintained in the early 2000s, and ...
1
vote
1answer
69 views

How to convey lifetime requirements?

Usually I use std::unique_ptr to convey ownership and pass in raw pointers as parameters when no ownership is implied. However, I almost never consider a nullptr to be acceptable as an argument, so it ...
0
votes
0answers
29 views

Offload traces into shared memory

There is a task to trace thread execution activity for posthumous analysis with minimum impact on latency/performance. Stack trace might be not enough to understand the reason of crash. Initially I ...
1
vote
1answer
185 views

Are there advantages to declaring stack variables constant in C++

It's not clear to me what benefits there are of declaring your stack variables as constant in C++, I was hoping somebody might explain the benefits and purpose for this technique. For example: void ...
2
votes
2answers
392 views

Doing work in vector's push back

I often use the following syntax: std::vector<foo> vec; vec.push_back( someClass.getFoo(...).modifyAndReturn() ); Considered about exception safety, I quote the standard on vector's push back ...
4
votes
3answers
517 views

What are my options for using a C++11 library in a C# WPF application? [closed]

I am writing a cross-platform (OS X and Windows) desktop application in C++11. I intend to use the same C++11 core on both platforms, utilizing native frameworks for the UI (Cocoa and Objective-C on ...
-1
votes
1answer
191 views

Live share prices for a side project [closed]

Me and some of my friends would want to start a side project which we will work at our spare time. Here is our criteria 1) A challenging project which will teach us skills which has business value in ...
8
votes
7answers
2k views

Is it a bad practice to include all the enums in one file and use it in multiple classes?

I'm an aspiring game developer, I work on occasional indie games, and for a while I've been doing something which seemed like a bad practice at first, but I really want to get an answer from some ...
0
votes
1answer
112 views

How to provide a custom ID to a downloadable application?

I've noticed that with remote support services, a technician usually sends you a download link to an executable. When you click on that link, it installs a software which automatically connects with ...
1
vote
2answers
146 views

Data retrieval and indexing

I have around 800,000 rows of data stored in the boost shared memory from the database. The data are in the form: Id Color Length Size 1 1 2 ...
15
votes
3answers
846 views

Is there a compliance test for C++ compilers?

Is there, somewhere, a freely usable/accessible script, source file, or whatever, that is able to measure the compliance of a given C++ compiler? For example, the Acid3 test for browsers: ...
2
votes
2answers
237 views

Trying to get a better understanding of object-oriented design's performance pitfalls

I'm currently in a high-performance computing class taught in C++. Usually, I do work in C#, meaning everything is taken care of for me, and optimization comes behind maintainability and higher-level ...
0
votes
4answers
302 views

Binary Search seems superior, why did the committee of C++ still have Find in the algorithm library?

I wish to search for an integer in a vector of integer. I have two candidates for the job: Binary Search Find It seems that Binary Search is the best candidate for the job as although I have to ...
0
votes
1answer
143 views

Is TCP message order still guaranteed when using async IO

Here the scenario I'm imagining. Two messages are transferred, both will require 2 packets each (I know you don't deal with packets directly with TCP, but on the IP level each message will consist of ...
0
votes
2answers
408 views

How do I pass a variable's value from one class into another? (C++)

I have a class ("Class A", we'll call it) which calculates the value of a private variable (which we can call numLoaves) with a public function. I need to use the value of numLoaves in a public ...
1
vote
6answers
542 views

Coming from high-level to C [closed]

I have a web background that grants me basic understanding over programming. Some older kids wouldn't even call that programming knowledge ("any moron can do PHP/Python/Ruby"), I guess, but let's not ...
1
vote
2answers
299 views

Decouple GUI & Program logic

I have some windows c++ code (pure winapi c++, no MFC etc) that I would like to build a GUI for. My code does not know about windows GUI, it is completely decoupled from any type of UI. The question: ...
1
vote
1answer
410 views

Implementation of deque in C++ with an array

How is the end() function implemented in deque-STL of C++ with array? As per my knowledge it returns past-the-end element. But when a loop is run like, for(i=deq.begin();i!=deq.end();i++) and the ...
4
votes
4answers
2k views

Do I need to understand pointers to use C++?

Well, I love C++, I have been using it for a while: I like all the libraries (Allegro, SDL, QT, Ogre, etc.), but I have a problem: I don't understand pointers. Do I really need them ? I just program ...
25
votes
11answers
5k views

I am a beginner. Can I directly start learning C++11? or I have to learn old C++? [closed]

I'm a beginner and have only little knowledge in programming. Would it be good if I directly learn C++ from books which cover new C++11 or should I study through the old best C++ books? Should I ...
1
vote
2answers
115 views

Maintaining independence between modules

I am reading Algorithms 4th Edition by Robert Sedgewick and in chapter 1.2 it discusses API design. It says: "The key to success in modular programming is to maintain independence between modules. ...
-1
votes
1answer
151 views

C++ program compiles fine, but I get a number of odd errors at runtime [closed]

So I've got a little experience in java, and recently I thought it would be nice to branch into c++. I've done a little programming in it, but I still know very little about the language. Recently, I ...
1
vote
0answers
131 views

How to organize points on a sphere in bins and navigate between bins?

I'm having trouble coming up with a suitable way to navigate through a set of star coordinates in the Equatorial Coordinate System. My goal is to display those which are within a given range of ...
14
votes
2answers
642 views

Which is better: a bunch of getters or 1 method with a selection string parameter?

Our knowledge domain involves people walking over a pressure-recording plate with their bare feet. We do image recognition which results in objects of the 'Foot' class, if a human foot is recognized ...
2
votes
3answers
341 views

To store data or not?

I'd like to ask you about one simple thing. I have class A that do something (for example counts something ). There is also one class B that handle some parameters to this class (class A is member of ...
1
vote
2answers
219 views

How to deliver 3 different parameters to class in one method (2 of 3 are optional)

I need your help how to implement it nice and well. It's quite a simple problem. I can solve it but I need help on how to do that better. My class has logic working using three parameters. It gets ...
2
votes
3answers
159 views

What's the best way to retrieve a value and a status [closed]

Given that all else is equal, and there are no coding standards defining the best approach, what would be the recommended way in C++ to check that a value exists and return it if it does? For ...
0
votes
3answers
2k views

C++ Performance vs. Java/C# [closed]

My understanding is that C/C++ produces native code to run on a particular machine architecture. Conversely, languages like Java and C# run on top of a virtual machine which abstracts away the native ...
0
votes
1answer
145 views

distributed computing with remote hetrogenous machines

The way i am doing it now is using boost::asio TCP sockets handling everything manually with a main server that orchestrates the processes between the available machines, but the number of machines ...
0
votes
0answers
84 views

R* Tree work with dynamic data

I'm searching an algorithm to store my data (which are moving objects' coordinates) and allow me to query objects within a specific radius of a specific point. I came up with R* Tree which is said as ...
1
vote
1answer
246 views

Is there already a “Binder” data-structure?

I was thinking of a data structure that I cannot describe better than with the word "book", or more exactly "binder". I was wondering if this had already been implemented in libraries like Boost or ...