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

learn more… | top users | synonyms

3
votes
5answers
450 views

Does comparison operand order affect speed?

I notice that someone in my organization programs comparisons like: if (100 == myVariable) rather than: if (myVariable == 100) He claims the former is quicker in languages like C++. I can't ...
7
votes
9answers
2k views

What is the way to understand someone else's giant uncommented spaghetti code? [duplicate]

Possible Duplicate: I’ve inherited 200K lines of spaghetti code — what now? I have been recently handled a giant multithreaded program with no comments and have been asked to understand ...
12
votes
4answers
747 views

Co-worker uses ridiculous commenting convention, how to cope? [closed]

A co-worker in the small start-up I work at writes (C++) code like this: // some class class SomeClass { // c'tor SomeClass(); // d'tor ~SomeClass(); // some function void ...
3
votes
1answer
804 views

combining ruby and C++

I've been discussing a conceptual project with a friend of mine and the the most effective way we've seen of doing it is writing the engine in C++ while the logic would be done in Ruby. However, we ...
2
votes
2answers
231 views

Which numeral systems are useful in computer science?

I am wondering which numeral system different programmers are using, or would use if their language has support for them. As an example, in C++ we can use: Octal by prefixing with 0 (e.g. 0377) ...
8
votes
4answers
3k views

Is it important to know C/C++ for Android development?

Is it possible to use only Java (without C++ /NDK) for building good, fast, beautiful Android apps (including 3D development)? When I look for Android developer position requirements (vacancies), I ...
0
votes
2answers
269 views

Visual C++, CMap object save to blob column

I have a MFC CMap object, each object stores 160K~ entries of long data. I need to store it on Oracle SQL. We decided to save it as a blob. Since we do not want to make additional table, we also ...
0
votes
1answer
568 views

C++ Building Static Library Project with a Folder Structure

I'm working on some static libraries using visual studio 2012, and after building I copy .lib and .h files to respective directories to match a desired hierarchy such as: ...
5
votes
1answer
114 views

How can I port msvc++ code with non-dependent names in templates to Linux?

I can deal with porting platform dependent functions. I have a problem that the compilers I tried on Linux (clang and g++) do not accept the following code, while the msvc++ compiler does: template ...
3
votes
2answers
836 views

Simplifying C++11 optimal parameter passing when a copy is needed

It seems to me that in C++11 lots of attention was made to simplify returning values from functions and methods, i.e.: with move semantics it's possible to simply return heavy-to-copy but ...
-1
votes
1answer
282 views

good c++ editor [closed]

I'm going to teach teenagers some C++ code. I need an editor which is simple and has built in compiler. We tried CodeBlocks but when we installed it in the machines, the text got reversed, I'm not ...
8
votes
2answers
519 views

Is this paragraph in Code Complete 2 backwards, or am I misunderstanding it?

In chapter 13, when talking about pointers, there is a paragraph: Sometimes, however, you would like to have the semantics of pass by reference—that is, that the passed object should not be ...
17
votes
6answers
5k views

Is it a good practice to use smaller data types for variables to save memory?

When I learned the C++ language for the first time I learned that besides int, float etc, smaller or bigger versions of these data types existed within the language. For example I could call a ...
4
votes
1answer
1k views

Best Creational Pattern for loggers in a multi-threaded system?

This is a follow up question on my past questions : Concurrency pattern of logger in multithreaded application As suggested by others, I am putting this question separately. As the learning from ...
14
votes
9answers
2k views

Isn't class scope purely for organization? [duplicate]

Isn't scope just a way to organize classes, preventing outside code from accessing certain things you don't want accessed? More specifically, is there any functional gain to having public, protected, ...
2
votes
3answers
980 views

How to define a code snippet in Java [closed]

I know about static final equivalent to #define , But I am not looking for it I have used #define REP(i,n) for(__typeof(n) i=0; i<(n); i++) in C++ and after that I can use REP(i,10) instead of ...
1
vote
1answer
325 views

Does putting types/functions inside namespace make compiler's parsing work easy?

Retaining the names inside namespace will make compiler work less stressful!? For example: // test.cpp #include</*iostream,vector,string,map*/> class vec { /* ... */ }; Take 2 scenarios of ...
2
votes
1answer
384 views

Can Win32 message loops survive being ported to native linux?

I would like to port a large Win32 DLL to native linux in C++. I don't think I can use Wine for a DLL like mine, because users of the DLL would then also have to be in Wine, and then they would all ...
8
votes
2answers
6k views

Google Chrome Extension Development for Dummies?

I want to get started writing extensions for Google Chrome. I am a long time C, C++, Delphi, etc. developer for many years with some Java skills. I believe Chrome extensions are written in C++ but ...
9
votes
5answers
2k views

How do you pronounce the '…' operator [closed]

Now, in c++ '...' became a first class operator. In speech, how do you pronounce it? So far I've heard: dot dot dot triple dot ellipsis related: Is it OK to replace ... with ellipsis in writing? ...
3
votes
3answers
531 views

design for a parser to handle very large files

I have written a program which records protocol messages between an application and a hardware device which matches each application request with each hardware response. This is so that I can later ...
8
votes
2answers
805 views

The C++ web stack, is there one?

Java would be jsps and servlets (or a framework such as Spring) running on the JVM and tomcat (or glassfish etc). C# would be asp and C# running on dot.net framework and IIS ? (I have no experience ...
4
votes
1answer
775 views

What are the differences between Special Edition and the Third Edition of Stroustrup's The C++ Programming Language?

I'm buying a few C++ books after moving from Java. I obviously want to read the reference manual from the man himself, though I cannot tell the difference between these two editions. The special ...
85
votes
13answers
8k views

Way in over my head! (Dealing with better programmers) [closed]

I've just been hired as a member of a group that is developing in C++. For the last 11 years, I'd been coding on and off at my last job (some C, some Fortran, some C++). The coding I'd done was ...
14
votes
2answers
1k views

Can WinRT really be used at just the boundaries?

Microsoft (chiefly, Herb Sutter) recommends when using WinRT with C++/CX to keep WinRT at the boundaries of the application and keep the core of the application written in standard ISO C++. I've ...
15
votes
5answers
2k views

Why am I seeing so many instantiable classes without state?

I'm seeing a lot of instantiable classes in the C++ and Java world that don't have any state. I really can't figure out why people do that, they could just use a namespace with free functions in C++, ...
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 ...
2
votes
2answers
2k views

Passing variables from PHP to C++

I need to call a program from PHP and pass some vars and/or sets of key-value pairs to it. How do I pass these vars, through arguments to the called function? exec("/path/to/program flag1 flag2 ...
2
votes
4answers
854 views

what are some good interview questions for a position that consists of reviewing code for security vulnerabilities? [closed]

The position is an entry-level position that consists of reading C++ code and identifying lines of code that are vulnerable to buffer overflows, out-of-bounds reads, uncontrolled format strings, and a ...
5
votes
2answers
306 views

Data structures for storing finger/stylus movements in drawing application?

I have a general question about creating a drawing application, the language could be C++ or ObjectiveC with OpenGL. I would like to hear what are the best methods and practices for storing strokes ...
5
votes
3answers
3k views

Actor library / framework for C++ [closed]

In the C++ project I am working on, we have an application consisting of several processes deployed on different machines. This network of processes is dynamic since processes (clients or background ...
8
votes
3answers
1k views

How to calculate Sin function quicker and more precisely?

I want to calculate y(n)=32677Sin(45/1024•n), where y is an integer and n ranges from 0 to 2048. How can I make this process quicker and more precisely? Now I want to show you a reference answer: ...
0
votes
3answers
761 views

Reconstruct a file from a TCP stream

I have a client and a server and a third box which sees all packets from the server to the client (but not the other way around). Now when the client requests a file from the server (over HTTP), the ...
6
votes
1answer
169 views

Unit testing a text index

Consider a text index such as a suffix tree or a suffix array supporting Count queries (number of occurrences of a pattern) and Locate queries (the positions of all the occurrences of a pattern) over ...
4
votes
1answer
1k views

How to implement child-parent aggregation link in C++?

Suppose that I have three classes P, C1, C2, composition (strong aggregation) relations between P <>- C1 and P <>- C2, i.e. every instance of P contains an instance of C1 and an instance ...
11
votes
2answers
462 views

FP for simulation and modelling

I'm about to start a simulation/modelling project. I already know that OOP is used for this kind of projects. However, studying Haskell made me consider using the FP paradigm for modelling a system of ...
7
votes
6answers
2k 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 ...
5
votes
4answers
1k views

Maintaining C/C++/Java skills as a web developer [closed]

When I was in college I learned how to program in C, C++, and Java. Currently, I'm a web developer using front end and back end technologies (HTML/CSS/JS, PHP, MYSQL). While the sorting algorithms and ...
3
votes
1answer
700 views

How are crossplatform/multiple-OS C++ projects planned in terms of code and tools?

I want to create a project in C++ that can work in Windows, Linux and Embedded Linux. How are projects created when they have to work across many OS'es? Is it first created on one OS and then the ...
2
votes
1answer
6k views

Most efficient Implementation a Tree in C++

I need to write a tree where each element may have any number of child elements, and because of this each branch of the tree may have any length. The tree is only going to receive elements at first ...
1
vote
3answers
694 views

Common header file for C++ and JavaScipt

I have an app that runs a C++ server backend and Javascript on the client. I would like to define certain strings once only, for both pieces of code. For example, I might have a CSS class ...
3
votes
1answer
158 views

Using T[1] instead of T for functions overloaded for T(&)[N]

The asio::buffer function has (void*, size_t) and (PodType(&)[N]) overloads. I didn't want to write ugly C-style (&x, sizeof(x)) code, so I wrote this: SomePacket packet[1]; // SomePacket is ...
4
votes
1answer
1k views

JavaFX 2.0 vs Qt for cross platform stand-alone application [closed]

I need a bit of advice from you developers who deal with cross-platform applications (specifically programs with a GUI). I will be creating an application soon that needs to be cross-platform and so ...
2
votes
1answer
1k views

Serializing network messages

I am writing a network wrapper around boost::asio and was wondering what is a good and simple way to serialize my messages. I have a message factory which can take care of dispatching the data to the ...
5
votes
3answers
10k views

Efficient way to find unique elements in a vector compared against multiple vectors

I am trying find the number of unique elements in a vector compared against multiple vectors using C++. The vectors are in sorted order and it can be of size 2,000,000. Suppose I have, v1: 5, 8, 13, ...
47
votes
6answers
17k views

Is `catch(…) { throw; }` a bad practice?

While I agree that catching ... without rethrowing is indeed wrong, I however believe that using constructs like this: try { // Stuff } catch (...) { // Some cleanup throw; } Is acceptable in ...
2
votes
2answers
454 views

How to translate formulas into form of natural language?

I am recently working on a project aiming at evaluating whether an android app crashes or not. The evaluation process is 1.Collect the logs(which record the execution process of an app). ...
7
votes
3answers
15k views

Cross-platform desktop programming: C++ vs. Python [closed]

Alright, to start off, I have experience as an amateur Obj-C/Cocoa and Ruby w/Rails programmer. These are great, but they aren't really helpful for writing cross-platform applications (hopefully ...
1
vote
1answer
463 views

Linking application build number to svn revision

I am looking for a strategy to version an application with the following requirements. My requirements are given an exe with version number (major.minor.build-number) 1) I want to map the version to ...
2
votes
1answer
550 views

Resolving equivalence relations

I am writing a function to label the connected component in an image (I know there are several libraries outside, I just wanted to play with the algorithm). To do this I label the connected regions ...