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

learn more… | top users | synonyms

3
votes
4answers
386 views

Does it still make sense to think about effective code on micro scale in C++?

Early in my programming career I was in love with pointer twiddling, lean code, doing everything with as little layers of abstraction as possible and so on. The code was very C like I would say, close ...
1
vote
2answers
648 views

Nice iterator naming [closed]

How do you name your iterators when you return a begin and an end iterator from a class? Without it sounding clunky, that is. Example: typedef std::vector<Idea> Ideas_Type; ...
21
votes
1answer
2k views

Is C++.Net used extensively?

I am a C++ coder by tradition. Over the last 12 months or so I have been doing a lot of C# coding, and have been pleasantly surprised by C#'s pragmatic approach (once I stopped trying to code it as ...
3
votes
2answers
180 views

How to find an error in a tcp server application for which there is no source code

I have a c++/cli tcp client application sending a data in a specific format like L,20100930033425093,-5.929958,13.164021 to a main application on port 9000.The main application is actually done by the ...
5
votes
3answers
2k views

How should I encapsulate database access?

What are some examples of good class structures used to manage database access? I am a fan of class encapsulation and would prefer the containers (e.g. car) not to perform database tasks. I would ...
1
vote
3answers
406 views

Is an API in C++ a better alternative to computing directly in SQL?

I need to perform large amounts of computations on data storerd in a busy Microsoft SQL server. Would it be faster if I retrieve the data from the server, perform the computations locally in C++, and ...
0
votes
3answers
401 views

Starting C++ Programming (for a C# Developer) [closed]

I am a C# developer. I am planning to learn C++. (I hope I will be able to leverage the OOP concepts from C#] I have a Windows 7 machine. What are the tools that I need to install for C++ ...
1
vote
2answers
847 views

How do you accept arguments in the main.cpp file and reference another file?

I have a basic understanding of programming and I currently learning C++. I'm in the beginning phases of building my own CLI program for ubuntu. However, I have hit a few snags and I was wondering if ...
1
vote
2answers
701 views

How to change careers [closed]

For the past 4 years I have worked in c# doing web development. I have really enjoyed it, learnt a lot and have a worked hard to get to a position where I am earning good money and enjoy the work. ...
1
vote
2answers
257 views

Oracle has some very helpful and free code…I think

I found that some of the code that Oracle uses is very useful so I don't have to re-invent the wheel. Given this is at the top of the file where the code in question is: /* * Copyright (c) 1997, ...
2
votes
4answers
610 views

The benefits of using RAII in C++

Suppose I'm a teacher and I want to explain to my students what are the benefits of using RAII in C++: I need a very good example, full of details, but that is easy to understand. Which approach ...
2
votes
3answers
2k views

Can I make a good career with VC++ programming? [closed]

I'm addicted to VC++ since 2008, and I begin to work for my current company from 2011 when I graduated in Mathematics. Now I still love VC++, it is a wonderful programming language. I'm a little ...
4
votes
3answers
4k views

Is it important to obfuscate C++ application code?

In the Java world, it seems to sometimes be a problem, but, what about C++? Are there different solutions? I was thinking about the fact that someone can replace the C++ library of a specific OS ...
1
vote
1answer
192 views

The design of a generic data synchronizer, or, an [object] that does [actions] with the aid of [helpers]

I'd like to create a generic data-source "synchronizer," where data-source "types" may include MySQL databases, Google Spreadsheets documents, CSV files, among others. I've been trying to figure out ...
3
votes
5answers
860 views

It's ok to study the C++ from a book that only support the 1998 version of standard?

I have this big book that basically covers all the main aspects of the C++, the problem is that is pretty old according to the C++ standards of today, it's ok to use it?
1
vote
3answers
882 views

Writing cross-platforms Types, Interfaces and Classes/Methods in C++

I'm looking for the best solution to write cross-platform software, aka code that I write and that I have to interface with different libraries and platforms each time. What I consider the easiest ...
1
vote
1answer
2k views

Missed question in technical phone interview and the follow up letter [closed]

I may have just bombed a C++ technical phone interview. The interviewer asked mostly about data structures and I was able to go into detail about each of the data structures he asked about. Score one ...
1
vote
2answers
407 views

Efficient way to compare scene-graph trees

I'm designing a scene graph system, where it is required to compare two trees. The trees are populated with individual objects, each with varied number of children; and they have a root. Eg: Parent: ...
3
votes
2answers
187 views

Custom graph comparison?

I'm trying to compare two graphs using hash value ( i.e, at the time of comparison, try to avoid traversing the graph ) Is there a way to make a function such that the hash values compared can also ...
2
votes
4answers
2k views

C++ Iterator lifetime and detecting invalidation

Based on what's considered idiomatic in C++11: should an iterator into a custom container survive the container itself being destroyed? should it be possible to detect when an iterator becomes ...
0
votes
1answer
737 views

Updating and organizing class diagrams in a growing C++ project

I am working on a C++ project that is getting bigger and bigger. I do a lot of UML so it was not really hard to explain my work to co-workers until now. Lately I implemented a lot of new features and ...
7
votes
9answers
2k views

Is it any good to use binary arithmetic in a C++ code like “C style”?

I like the fact that the C language lets you use binary arithmetic in an explicit way in your code, sometimes the use of the binary arithmetic can also give you a little edge in terms of performance; ...
2
votes
2answers
496 views

The best way to have a pointer to several methods - critique requested

I'm starting with a short introduction of what I know from the C language: a pointer is a type that stores an adress or a NULL the * operator reads the left value of the variable on its right and ...
0
votes
1answer
346 views

Implementing a “state-machine” logic for methods required by an object in C++

What I have: 1 hypothetical object/class + other classes and related methods that gives me functionality. What I want: linking this object to 0 to N methods in realtime on request when an event is ...
8
votes
4answers
1k views

Undefined behaviour in Java

I was reading this question on SO which discusses some common undefined behavior in C++, and I wondered: does Java also have undefined behaviour? If that is the case, then what are some common causes ...
18
votes
9answers
4k views

General programming techniques to speed up coding time

I am preparing for a programming contest where we have to code in C++ and it is all about producing working code in a short time. An example would be to use a macro to get the minimum of two ints or ...
2
votes
3answers
2k views

function works fine without return value in c++

I forgot to write return 'a'; in function and return 0; in main function but its works fine in Code::Blocks. #include <iostream> using namespace std; char show() { cout<<"this is show ...
0
votes
1answer
275 views

Is there any benefit of using one language over the other for competitive programming websites like SPOJ or TopCoder? [closed]

I know a bit of C++, Java and Ruby. I want to be proficient in one of these now and I don't know how to pick. I was wondering if picking one over the other would be advantageous in any way for ...
4
votes
2answers
478 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
530 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
418 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
787 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
281 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
201 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
10k 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
334 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
7k 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
136 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
482 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
381 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
13k 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
4k 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
1k 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
697 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 ...
12
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
274 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, ...