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

learn more… | top users | synonyms

8
votes
8answers
2k views

Is STL implemented with OO?

There are several design patterns like Adaptor, Iterator implemented in STL. Does that mean STL is implemented with OO concepts? What is the relationship between OO and template parts of C++? I ...
3
votes
4answers
776 views

strategies to keep tabs of memory leaks in non memory-managed languages

When it comes to non memory managed languages such as C, C++ or Fortran (my case), it becomes increasingly difficult to keep track of memory allocation/deallocation, especially when ownership must be ...
0
votes
0answers
210 views

Which programming language is Curiosity written in? [duplicate]

Possible Duplicate: What is the Mars Curiosity Rover's software built in? I only recently came across an article that stated there was well over 500,000 lines of code in Curiosity and I ...
5
votes
13answers
925 views

Limitations of Polymorphism in statically typed languages

I program mostly in statically typed languages, like C++ and Java. A common strategy employed in languages like these to handle dealing with collections of objects which are related, but which need ...
17
votes
6answers
6k views

Dependency injection ; good practices to reduce boilerplate code

I have a simple question, and I'm not even sure it has an answer but let's try. I'm coding in C++, and using dependancy injection to avoid global state. This works quite well, and I don't run in ...
5
votes
10answers
609 views

I'm at a crossroads with programming and theory [closed]

I bought "Beginning C++ Through Game Programming" yesterday to start learning about C++ and programming. I'm going on hour 33, and I can't seem to put this book down. I was talking to a friend who's ...
85
votes
11answers
22k views

What backs up the claim that C++ can be faster than a JVM or CLR with JIT? [closed]

A reoccurring theme on SE I've noticed in many questions is the ongoing argument that C++ is faster and/or more efficient than higher level languages like Java. The counter-argument is that modern JVM ...
1
vote
1answer
108 views

How to represent association in programs [closed]

Could someone help me in implementing association in cpp. I am trying to implement a dice game where I have two classes a diegame and a dice.
0
votes
0answers
71 views

Singletons in C++, are they really necessary, used? [duplicate]

Possible Duplicate: When is Singleton appropriate? Ok, most people probably know what a singleton is, use them, and know all the drawbacks including race conditions and so on. But what I ...
13
votes
6answers
1k views

Homework for strong C++ developers learning Java

I'm tasked with teaching an accelerated university special topics course in Java for programmers with many years of experience in C/C++. What sort of medium-length (1-2 hours max) assignments would ...
0
votes
4answers
17k views

2 Dimensional Arrays in C++

I started learning arrays in C++ and came over a little side note in the book talking about 2D arrays in breif. I tested it out and i was amazed that it could give the programmer the ability to store ...
28
votes
7answers
4k views

Explanation on how “Tell, Don't Ask” is considered good OO

This blogpost was posted on Hacker News with several upvotes. Coming from C++, most of these examples seem to go against what I've been taught. Such as example #2: Bad: def ...
6
votes
2answers
326 views

C++ Class Initalization

I'm a python programmer who sees a lot of C++ code but doesn't know the language and there seems to be two ways to initalize a class. I was hoping that someone can tell me the difference. class Point ...
14
votes
3answers
2k views

Why isn't the arrow operator in C++ just an alias of *.?

In c++, the * operator can be overloaded, such as with an iterator, but the arrow (->) (.*) operator does not work with classes that overload the * operator. I imagine that the preprocessor could ...
12
votes
3answers
4k views

Unit testing C++: What to test?

TL;DR Writing good, useful tests is hard, and has a high cost in C++. Can you experienced developers share your rationale on what and when to test? Long story I used to do test-driven development, ...
1
vote
2answers
616 views

Is C++ really going out of fashion? [closed]

The TIOBE index claims that the popularity of C++ is waning, and is currently way below C and Java. Echoing this claim, a blogger suggested today, that because C++ is going out of fashion, C++ ...
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
668 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
412 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
403 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
864 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
707 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
613 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
873 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
911 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
417 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
762 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
507 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
352 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
281 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
479 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
544 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
419 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
801 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 ...