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

learn more… | top users | synonyms

5
votes
2answers
270 views

Why Increment Pointers?

I just recently started learning C++, and as most people (according to what I have been reading) I'm struggling with pointers. Not in the traditional sense, I understand what they are, and why they ...
-2
votes
0answers
31 views

Programming advice with DFHack [on hold]

Me and a Friend are looking to develop a plugin for the DFHack console of the popular game Dwarf Fortess. Pretty much what we had planned out was a way to utilize multiple cursors, or a way to make ...
2
votes
1answer
58 views

How to define the motion path of one object on a surface of the other one?

I have an uncommon problem. There are 2 3D objects, which are represented by arrays of vertices and triangles (.stl files). Each of them contains a big enough amount of vertices: 1-10 mln ones. The ...
4
votes
1answer
195 views

Is there a reason to define type aliases in any program

I have started to learn c++ for some time ago. It is a big subject and I am not very use to it yet. Thus is this question asked more of curiosity, than something else. In the book that I read to now ...
6
votes
4answers
453 views

Are there technical limitations or language features that prevent my Python script from being as fast as an equivalent C++ program?

I'm a long-time Python user. A few years ago, I started learning C++ to see what it could offer in terms of speed. During this time, I would continue to use Python as a tool for prototyping. This, it ...
-5
votes
0answers
91 views

Dow Jones “Print” C++ [on hold]

I am in the process of learning c++ through my friend challenging me to make certain programs (calculator, file opener/saver etc). This time I have been challenged to make a function that returns the ...
0
votes
5answers
314 views

IS C++ a cross-platform language? [on hold]

If I create a game in C++ on a mac using a library which is the same for both windows and osx, will the game be playable on both windows and os x or it will only work in os x because I done it in ...
0
votes
5answers
182 views

learning algorithms or learning a new language [on hold]

So I've been self studdiing two things. Algorithms/data structures using java and learning c++. I have books for both. But I'm slowly finding out that learning these two and doing CRUD programming in ...
-6
votes
0answers
66 views

How this problem has been solved? [closed]

Little Jhool solves huge mathematical questions, for which people usually use super-computers, and everything - but hey, this is Little Jhool we are talking about. This time it's not Little Jhool who ...
2
votes
1answer
112 views

Is there a way to use RAII techniques in COM?

I am caught between two conceptual models of how to construct objects, and am having trouble working out what standard I want to adopt. I prefer to program in .NET and often try to use RAII and ...
-2
votes
2answers
199 views

Which algorithm is faster? [on hold]

I'm creating a small game, where the computer generate pseudo random number in give range, and the user have to guess it. I also made the option to play computer vs computer. I mean the computer ...
0
votes
1answer
54 views

Is it a bad idea to use mutable for pre-allocated temporaries?

Let us assume I have the following C++ class: class MyFastMessageEncoder { public: MyFastMessageEncoder() : m_fieldEncoder(ENCODING_STYLE_DEFAULT) { } void ...
0
votes
0answers
16 views

LL1 Parsing Table, Output Table is not properly showing + buffer problem [migrated]

I tried my best what I can do to show this output table, but having hard time showing it. the code runs fine but when I try to enter the following output of table for validation, a lot of errors ...
0
votes
1answer
58 views

Analysis and design of algorithms final project [closed]

I'm searching a final project for my course of "analysis and design of algorithms" but I do not know what I can do. Let me explain it a bit: In this course we have learned 3 fundamental concepts: ...
-3
votes
2answers
258 views

How comes the C++ standards committee introduces a keyword like nullptr and gets away with it? [closed]

That must have broken a lot of peoples code bases right? Everyone who had a variable named "nullptr" (which I think would have been fairly common) has to find "nullptr" and replace with ...
0
votes
0answers
11 views

How can I pass floating point numbers as template parameters? [migrated]

I am working on a meta-programming project, and we would like to have the ability to pass floating-point numbers as template arguments. I wasn't sure whether this question would be better suited to ...
2
votes
2answers
110 views

Potentially justifiable use case for const_cast or bad design?

I'm designing a data structure in C++, and I want to expose an interface to the user to traverse the structure in some order. Instead of creating several different types of enumerators, I want to keep ...
0
votes
0answers
64 views

Dynamic programming in Bin packing

Problem: Given a list L of objects of possible sizes from set S={1,2,4,8} and unlimited supply of bins of sizes 16 each and we have to use minimum possible numbers of bins to pack all objects of L. I ...
2
votes
1answer
81 views

OpenGL's relationship to OpenGL ES (3.0)

I'm beginning my journey into graphics programming and want to learn OpenGL. Because I'm green to graphics programming but not to C and C++, a familiar question came up when I looked at OpenGL and ...
0
votes
3answers
269 views

Is there still any value in learning assembly languages today? [closed]

Specifically for a game programmer. If you really needed some assembly routines you could look for help, whereas back in the 80s/90s it was one of the mainstream languages. I read that compilers can ...
2
votes
1answer
498 views

Why is C++ “this” poorly designed?

1) For every a and b which are non-const pointers of the same type, you can do a = b;, right? 2) Inside non-const member functions the this keyword exists, which is a non-const pointer. So logicaly ...
2
votes
1answer
143 views

Is it poor form to use C features such as the size_t type instead of their c++, such as std::size_t?

I have recently been told that using size_t as declared in the global namespace is incorrect in C++, ostensibly because size_t is a C-feature. I looked this up and came across this question on Stack ...
1
vote
0answers
50 views

Simulation of a point mass in a box (3D space) [migrated]

I would like to simulate a point mass within a closed box. There is no friction and the point mass obeys the impact law. So there are only elastic collisions with the walls of the box. The output of ...
19
votes
5answers
6k views

Is it a good idea to “#define me (*this)”?

This macro can be defined in some global header, or better, as a compiler command line parameter: #define me (*this) And some usage example: some_header.h: inline void Update() { /* ... */ } ...
0
votes
1answer
70 views

Microsoft Visual C++ Redistributables, Software Requirement? [closed]

When compiling with Visual Studio C++, I noticed that you need a specific MSV C++ Redist, depending on the version of Visual Studio you compile with. The required redistributable is necessary on ...
0
votes
0answers
45 views

Web Services of System Integration

I have been assigned to a system integration project. However, I do not understand part of the integration implementation architecture. For example, I have a passport scanner connected to a Windows ...
0
votes
0answers
55 views

Memory management scheme for custom memory allocator

I am in the process of implementing a small memory manager. The users of this memory pool will always access the memory bytes via handles. So a memory allocation/deallocation is done with two APIs: ...
0
votes
0answers
77 views

GSP Algorithm explanation

I've been trying to implement the GSC algorithm in C++, however I need help with clarifying the definition: http://en.wikipedia.org/wiki/GSP_Algorithm GSP Algorithm makes multiple database ...
0
votes
2answers
153 views

Value of passing by reference [duplicate]

In C++, we have the option to pass by reference or pass by value. The client code does not need to know which one a parent function uses; that is, int func(int param) and int func(int &param) are ...
2
votes
1answer
58 views

Python API: Extension Module or Pure Module

We have a C++ application, with C++ interfaces changing regularly during development. We also have a C API which is designed to be stable in spite of such changes; the C API is tighly focused on ...
0
votes
1answer
68 views

OpenSSL Client model for half duplex communication over socket

I have read in this SO question that OpenSSL socket communication can be only half duplex in a single thread. Assuming what I have read is true, I am wondering if I can apply philosopher's dining ...
5
votes
2answers
500 views

How do I deal with classes that are only used once, say in only a single function?

I have a class that basically builds up a memory-efficient version of a structure to be used in a performance-critical section of code. The resulting structure is ugly but extremely fast, so not ...
3
votes
1answer
342 views

Why do programmers still use “SAFE_DELETE”? [closed]

If I had a dime for every time I've seen this macro in use, today I would be coding just for fun: #define SAFE_DELETE(p) if ((p) != NULL) { delete (p); (p) = NULL; } Why do programmers insist in ...
-1
votes
0answers
39 views

How do I stop characters sent to PuTTY screwing with its title/output? [migrated]

I'm sending JSON to PuTTY on Windows from a C++ program running on an mbed. I've escaped the characters \, /, ", \b, \n, \f, \r, \t as per json.org. But I still have three quirks that I do not ...
0
votes
3answers
237 views

What does “ (int) value & 0x1, (int) value & 0x2, (int) value & 0x4, (int) value & 0x8 means”

The "value" ranges from 0 to 15 (it's possible values). When will those 4 "if"condition be met? If my (int)value = 2 does this mean 0010? if ((int)value & 0x1) { ...
17
votes
4answers
554 views

How bad is it calling println() often than concatenating strings together and calling it once?

I know output to the console is a costly operation. In the interest of code readability sometimes it is nice to call a function to output text twice, rather than having a long string of text as an ...
2
votes
4answers
1k views

Going through The C Programming Language K&R in Visual Studio

From what I have read, K&R seems to be a good place to start learning programming in general, and C programming specifically. However, I've just started the first chapter and I have a few ...
3
votes
3answers
205 views

Data Oriented Design - impractical with more than 1-2 structure “members”?

The usual example of Data Oriented Design is with the Ball structure: struct Ball { float Radius; float XYZ[3]; }; and then they make some algorithm that iterates a std::vector<Ball> ...
2
votes
1answer
154 views

Code re-use in C++, via multiple inheritance or composition? Or…?

I originally asked this question on StackOverflow, but I was directed here, and I think my problem is perhaps as much conceptual as technical, so here goes. If you’re defining a hierarchy of abstract ...
2
votes
2answers
128 views

When does extracting methods from code stop to make sense? [duplicate]

I am currently studying the refactoring methods defined by Marting Fowler (http://refactoring.com/catalog/). He states a tip for replacing chunks of code by a single method that does that job. So ...
1
vote
4answers
599 views

Why would a C executable be smaller when compared to C++ executable

I'm trying to understand why the output file sizes are significantly different when using a C and a C++ compiler. I was writing a small hello world program in C and C++, I noticed that in C version, ...
0
votes
1answer
91 views

GUI code implementation for specific Window/Form class

Terminology Element/Form Element -> Fields such as text list, combo_boxes, push buttons, etc. Problem I have a program that is basically a fat client that interfaces into a system that keeps track ...
1
vote
3answers
139 views

How to make a random-access archive of text files?

I wrote an application that tests the performance of evolutionary algorithms. This application performs a run of the algorithm which consists of several generations. The data which is produced by my ...
2
votes
2answers
250 views

What is a good C++ API Design for HW registers?

I am designing an API for a driver that manipulates HW. I have done the following: namespace HWRegister { //private: namespace Data { //accessible only within this namespace ...
1
vote
3answers
82 views

Setting global parameters: is this a reasonable use of const_cast and volatile?

I have a program that I run repeatedly with various parameter sets. Different parameters are used in different parts of the program (including different source files). The same parameter may also be ...
2
votes
3answers
248 views

Transitioning from Java & C to C++

I learned Java and I'm pretty competent programming in it. I also learned C recently. I looked at a comparison between Java and C++ and I like C++'s features like operator overloading and its speed. ...
1
vote
1answer
130 views

Where does `this` go in a x64 thiscall?

So I understand that thiscall doesn't really exist in x64 programming. However, I can't really find any definitive explanation as to where the this pointer is put to be passed to the callee. Is a x64 ...
3
votes
2answers
339 views

Why doesn't C++ allow you to take the address of a constructor?

Is there a specific reason that this would break the language conceptually or a specific reason that this is technically infeasible in some cases? The usage would be with new operator. Edit: I'm ...
1
vote
3answers
144 views

Is storing pointer (of new'd object) in static collection from object constructor a common idiom in C++

In code I am reviewing a common approach I see to storing objects (eg a socket client object), is use a static container to hold the objects. The objects are created by some helper function, eg like ...
6
votes
4answers
453 views

Split up large interfaces

I'm using a large interface with about 50 methods to access a database. The interface has been written by a colleague of mine. We discussed this: Me: 50 methods is too much. It's a code smell. ...