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

learn more… | top users | synonyms

4
votes
2answers
468 views

HTML, JS, CSS Engines [closed]

I am just messing around, trying to figure out how stuff works and right now I have a couple questions about HTML, JS and CSS engines. I know there are two major JavaScript engines out there - V8 and ...
2
votes
2answers
510 views

For nodejs what are best design practices for native modules which share dependencies?

Hypothetical situation, I have 3 node modules all native, A, B, and C.  A is a utilities module which exposes several functions to javascript through the node interface, in addition it ...
1
vote
1answer
415 views

Incorporating GoF design patterns in Objective-C without Abstract/Virtual classes

As someone who is becoming more comfortable working in Objective-C I would like to be able to incorporate more design patterns and OOP features in my projects but struggle to implement them as ...
5
votes
8answers
1k views

Is there a point to writing in C or C++ instead of C# without knowing specifically what would make a program faster?

I wrote a small library in Python for handling the xbox 360's STFS files to be used on my web applications. I would like to rewrite it for use in the many desktop programs people are writing for 360 ...
1
vote
3answers
765 views

Pattern for Accessing MySQL connection

We have an application which is C++ trying to access MySQL database. There are several (about 5 or so) threads in the application (with Boost library for threading) and in each thread has a few ...
72
votes
19answers
5k views

Is it ok to replace optimized code with readable code?

Sometimes you run into a situation where you have to extend/improve some existing code. You see that the old code is very lean, but it's also difficult to extend, and takes time to read. Is it a good ...
1
vote
5answers
2k views

What is the point of dynamic allocation in C++?

I really have never understood it at all. I can do it, but I just don't get why I would want to. For instance, I was programming a game yesterday, and I set up an array of pointers to dynamically ...
5
votes
4answers
276 views

TDD: Write a separate test for object initialization or relying on other tests exercising it

This seems to be the common pattern that's emerging in some of the tests I've worked on lately. We have a class, and quite often this is legacy code whose design can't be easily altered, which has a ...
0
votes
1answer
199 views

non-volatile virtual memory for C++ containers

Is there a virtual memory management process that would allow a program to use the standard container structures and classes, but retain these structures and their data when the program is not running ...
6
votes
6answers
9k views

What does it mean to do a “null check” in C or C++?

I have been learning C++ and I am having a hard time understanding null. In particular, the tutorials I have read mention doing a "null check", but I am not sure what that means or why it's necessary. ...
1
vote
2answers
330 views

Can I develop OpenGL ES iPhone simple physics app with Xcode 3 in C++ without a GUI?

Can I develop OpenGL ES iPhone simple physics app with Xcode 3 in C++ without a GUI and Objective-C? So I don't need Cocoa and I don't need Objective-C?
47
votes
7answers
6k views

Why are there so many string classes in the face of std::string?

It seems to me that many bigger C++ libraries end up creating their own string type. In the client code you either have to use the one from the library (QString, CString, fbstring etc., I'm sure ...
1
vote
2answers
134 views

Class design, One class in two sources

Is it possible define methods from the same class in different "CPP" files? I have header file "myClass.h" with: class myClass { public: // methods for counting ... // methods for ...
3
votes
1answer
473 views

How to unit test with lots of IO

I write Linux embedded software which closely integrates with hardware. My modules are such as : -CMOS video input with kernel driver (v4l2) -Hardware h264/mpeg4 encoders (texas instuments) -Audio ...
5
votes
5answers
370 views

Alternatives for comparing data from different databases

I have two huge tables on separate databases. One of them has the information of all the SMS that passed through the company's servers while the other one has the information of the actual billing of ...
11
votes
4answers
2k views

Motivation and use of move constructors in C++

I recently have been reading about move constructors in C++ (see e.g. here) and I am trying to understand how they work and when I should use them. As far as I understand, a move constructor is used ...
15
votes
8answers
12k views

What is the best C++ source code to read for a beginner? [closed]

I'm trying to improve my c++ coding technique by reading c++ source code. Which open source project would you recommend? Is the code of Boost C++ Libraries a good one?
5
votes
3answers
3k views

Can a class be inside another class?

Here's an excerpt from "The C++ Programming Language" template<classT> class List { // optimal public: class Link { /* ... */ }; List (); // initially empty void put(T *); // put before current ...
13
votes
3answers
991 views

How would you unit-test or perform the most effective automated testing on graphics code for OpenGL?

I'm writing a game and the accompanying graphics engine on top of OpenGL in C++. Im also a fan of good coding processes and automated testing. Graphics code + testing seems pretty immiscible, since ...
7
votes
3answers
666 views

Interfacing application code with unit tests

I am working on a project in which we have to implement and unit test some new module. I had a quite clear architecture in mind so I quickly wrote down the main classes and methods and then we started ...
11
votes
6answers
2k views

Why C++ to write a compiler?

I was wondering why C++ is a good choice to write a compiler. Of course C is good for this purpose too, because many compilers are written either in C or C++ but I am more interested in C++ this time. ...
2
votes
1answer
273 views

Beginning development of a C++ project

I study in software engineering and this year a new association at my university is opening a robotic submarine club. It's a new club and they needed software guys for micro-controllers manipulation, ...
0
votes
4answers
556 views

Objective-C message passing related queries

I am learning objective-C after having good knowledge of C/C++. I have 2 questions: Are Obj-C message passing and C++ vtable, two different ways of implementing polymorphism or Are they two very ...
15
votes
8answers
1k views

Plagued by multithreaded bugs

On my new team that I manage, the majority of our code is platform, TCP socket, and http networking code. All C++. Most of it originated from other developers that have left the team. The current ...
3
votes
3answers
937 views

Can coding style cause or influence memory fragmentation?

As the title states, I'd like to know if coding style can cause or influence memory fragmentation in a native application, specifically one written using C++. If it does, I'd like to know how. An ...
7
votes
6answers
5k views

Design: Calling back to the parent class

When modelling an object with children it's common to include the children via composition, as a member of the parent class. Sometimes however the children need to tell the parent something, they need ...
4
votes
1answer
622 views

Which data structure to represent a triangular undirected graph

I was wanting to create a graph similar to this in C++: The one I will implement will have more edges and vertices, but will use this triangle style. I was wanting to create something that I could ...
7
votes
6answers
1k views

Excellent knowledge of C++ [closed]

I recently saw a recruiting page for a software company where one of the requirements was "Excellent knowledge of C++." Now, I know this somehow implies as expert knowledge of C++, but where exactly ...
1
vote
3answers
6k views

how to nicely use constant std::string in c++

In my current code project, there is an awful lot of constant strings I use to print out error messages. Hardcoding such strings is generally considered to be bad practice. Now I'm searching for a ...
2
votes
4answers
4k views

What sorting algorithm does STL use?

I recently started using <vector.h> library and I was wondering, since all the operations are already implemented, IF the method of the sorting algorithm is the most efficient one. Everything ...
5
votes
5answers
648 views

Would “Efficient C++” book be irrelevant now due to compiler improvements?

I am planning on purchasing this book to learn more about C++ programming with regards to fast code. However, the book was published in 1999 and I am worried most of it may be irrelevant now due to ...
3
votes
3answers
263 views

Global Texture Container

For my first large-ish endevor in Open-GL I'm making a simulator of sorts. I've got much of the basic functionality working, but recently ran into a problem. As I've since realized, I originally ...
9
votes
5answers
13k views

Should I use the new C++11 'auto' feature, especially in loops?

What are the pros/cons to using the auto keyword, especially in for loops? for(std::vector<T>::iterator it = x.begin(); it != x.end(); i++) { it->something(); } ...
0
votes
3answers
718 views

C++ “under the hood” books for advanced readers? [closed]

Are there any particularly good books for understanding how C++ works "under the hood"? My reasons for asking this are that I am very interested in C++ performance system programming (low latency ...
8
votes
5answers
1k views

What is a good way to represent a many-to-many relationship between two classes?

Let's say I have two object types, A and B. The relationship between them is many-to-many, but neither of them is the owner of the other. Both A and B instances need to be aware of the connection; ...
2
votes
8answers
3k views

Understanding C++ for windows desktop application

I've been programming C++ for almost a year, and I've written complex programs however there are a couple of programming features of C++ which I didn't cover up (Classes & pointers), however I ...
11
votes
2answers
2k views

Best overview to modern C++ paradigms?

I used to write C++ extensively between 8 and 10 years ago. I have since moved on to C# for professional reasons. However, from time to time I see statements like "If you're still manually ...
3
votes
1answer
567 views

C++ compiler structures such as Virtual method Table etc

I am aware of the C++ Virtual Table which allows dynamic dispatch for doing things at runtime (although if I am honest I am not completely sure of the full list of things it achieves). I am wondering ...
2
votes
3answers
600 views

introducing pointers to a large software project

I have a fairly large software project written in c++. In there, there is a class foo which represents a structure (by which i don't mean the programmers struct) in which foo-objects can be part of a ...
14
votes
7answers
6k views

What are the roles of singletons, abstract classes and interfaces?

I am studying OOP in C++ and, even though I am aware of the definitions of these 3 concepts, I cannot really realize when or how to use it. Let's use this class for the example: class Person{ ...
10
votes
3answers
1k views

How to handle interview questions on programming style

As a C++-programmer in interviews I repeatedly found myself in situations were the interviewer wanted to probe my knowledge of good programming style. These typically were centered around basic ...
9
votes
3answers
3k views

When to use typedef?

I'm a bit confused about if and when I should use typedef in C++. I feel it's a balancing act between readability and clarity. Here's a code sample without any typedefs: int ...
5
votes
4answers
7k views

How does one interface C++ with the web (at Google, for example)?

Google is well known for the ridiculous amount of C++ they've coded over the years. Correct me if I'm wrong, but a large part of Google's core search engine is written in C++, isn't it? How does one ...
8
votes
4answers
1k views

Where does Objective-C come from? C++ or C?

I am very confused about this programming language, Objective-C, which I heard is used to develop iOS applications. I know that it uses the principles of OOP. Would it be easier to learn if I already ...
4
votes
5answers
408 views

variable comparison without initialising

I am working with a project in VC++ which involves co-ordinate system having x,y,z axis. I am trying to check for if a variable(Point with x,y,z values) is assigned on the coordinate system or its a ...
5
votes
3answers
346 views

Filesystem like permissions for C++ type-members

Abstract (tl;dr) Please read the full question, this is awfully simplified: How can unix file permission style restrictions be applied to inter-type data/control flows, allowing fine-grained access ...
1
vote
2answers
499 views

Looking for good testing in multithreaded C or C++ open source projects [closed]

I have read a lot about the importance of unit testing, and testing in general. In particular I have read about TDD which, in theory, seems like a good way to ensure effective test coverage for a ...
4
votes
1answer
293 views

Generate analog signal from Windows 7 [closed]

I want to output an analog signal from my Windows 7 computer. The wave will be a combination of about 5 frequencies, with a maximum of 28 MHz. It won't be a problem to generate the wave data with C++, ...
5
votes
7answers
347 views

Which style is better to check and log the error?

I have read some code and here are two ways to check and log the error in cpp code that repeats in my project many times. Which way is better? 1. bool AClass::myMethod() { if (!SomeCondition()) ...
3
votes
2answers
730 views

Combining source files, like header files

I have a project where my files have gotten out of hand because of the volume of them. I have started to combine classes of similar types in single header files because you can, and it still is good ...