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

learn more… | top users | synonyms

-1
votes
0answers
74 views

Why are there few C++ remote works? [on hold]

I'm a C++ software engineer who, for personal reasons, would prefer to work remotely (telecommute). I can find a huge variety of telecommute and remote works for javascript, html, php, C#, java and ...
-2
votes
0answers
27 views

How do you write to a second console? (C++) [migrated]

I had the idea of using a second console in my programs for the purpose of logging programming activity. I looked around on msdn for related functions/examples and tried to put together a simple ...
3
votes
2answers
232 views

Should an object load itself?

although I'm programming in C++ for some time now, I'm always faced with design decisions (probably due to the language's flexibility). One such problem is deciding if a method should be part of the ...
-1
votes
2answers
87 views

Objects in smalltalk and c++

I have a question based on SmallTalk and C++. In one of the programming languages books, there is a question like: "Does an object in Smalltalk require its own private stack? What about in C++?" ...
-4
votes
0answers
39 views

Which library to display grid better in Conway Game of Life? [on hold]

I have implemented Conway's Game of Life in C++. I want to know which library shall i use to display the grid, as i am not satisfied with the output that i am getting on console. I need more control ...
-2
votes
0answers
39 views

How to compare two chars in C++? [on hold]

I have to extract 2 chars from a string and test them on being equal. How do I do this? My approach if (s[1] == s[2]) ... doesn't work.
5
votes
3answers
283 views

How to prevent others from using non-thread safe variables in a multithreading environment?

I have an application written in C++ that was originally single threaded, but, due to the increasing complexity of this project, I'll need to expand it to at least two or three threads. There are ...
-3
votes
1answer
93 views

What do you think about GUI-programming in Qt and all other frameworks usefullnesses [on hold]

What do you think about coding and desining? I mean, should we use code rather then designing all in forms. I think, it's kinda lazy to click in forms some buttons. Programmer should code, BUT i'm a ...
-1
votes
5answers
538 views

Determining the winning condition for Tic-Tac-Toe [on hold]

I'm writing a tic-tac-toe game in C++ and now I found a function to check if a player has a winning board for a connect four game. The function looks like this: bool haswon(int64_t board) { ...
-1
votes
0answers
42 views

SCJP like book for C++ [closed]

I read SCJP study guide two years ago and it helped me become a better Java programmer. I would like to use the same success recipe, so I'm asking : Do you know any C++ book that is structured like ...
0
votes
0answers
100 views

Why are the raw pointer values being overwritten/falling out of scope [migrated]

I have a C++11 function making calls against a legacy C function. I thought it would be good to create worker threads(using std::thread that will then pass variables to the C function. However, it ...
-2
votes
1answer
91 views

How would I go about editing memory in a Process via C++ DLL Injection? [on hold]

How would I go about editing memory in a Process via C++ DLL Injection? More specifically, how could one find the target location of the stored memory, and edit it using a C++ DLL that gets injected ...
-2
votes
0answers
62 views

Developing a Phone OS [closed]

I have created a project for myself: Develop my Own Operating System.. for a Mobile Phone (touch screen). I am new to this whole thing, I've started learning C and C++ but only in theory as of yet. ...
0
votes
0answers
79 views

What means that a paper has been adopted for pending C++ standard? [closed]

For example: "New core language papers adopted for C++17" http://isocpp.org/blog/2014/11/new-papers-adopted-for-cpp17 "New standard library papers adopted for C++17" ...
3
votes
2answers
2k views

Every function is a closure?

Wikipedia says, that closure - is a function, which has an access to variables, declared outside of the function. There is even an example: function startAt(x) function incrementBy(y) ...
1
vote
4answers
694 views

try/catch open/closed principle violation

I have three or more different custom exceptions that a class can throw and I need to use try/catch in order to discover which exception was thrown. In my point of view this piece of code violates ...
-1
votes
0answers
13 views

How to stop copying into array using fscanf when its the end of the line? [migrated]

I have a file that has lines like Bob, 2,3,13,4 Jim 3,4,15,3 ... and I'm trying to copy into my numbers array only the integers in each line, so that I could do some math with them. Problem is, I ...
0
votes
0answers
44 views

Accessing a stateful managed object from native code via a static variable [migrated]

I need to create a native C++ DLL that will be an interface/wrapper over a C# class. I've never done anything like this before, but my design is basically the same as this. In other words: I have a ...
38
votes
9answers
7k views

What did people do before templates in C++? [duplicate]

I am not new to programming, but I am one that started a few years ago, and I do love templates. But in the before times, how did people deal with situations where they needed compile-time code ...
0
votes
3answers
236 views

Using PHP or C++ for in real world electronic devices

I want to use my programing skills to make my day-to-day life easier, to do this I want to be able to program in my appliances like alarm clock or microwave or refrigerator, air conditioner etc, wish ...
3
votes
3answers
307 views

Should we add constructors to structs

We often use c++ structs to define data structure as opposed to class which can be a complete module with member methods. Now deep down, we know they both are the same (loosely speaking). The fact ...
-1
votes
1answer
181 views

Writing an Operating System in C [closed]

I've done some research in building an OS and I know that it has to be made using the assembly language. I've also seen that it can be built using the assembly language with C/C++. I was wondering ...
0
votes
1answer
166 views

Is factory pattern a right pattern for the situation described here?

Is factory pattern a right pattern when we want to consolidate the related objects? Problem - In the Set-top box, I have a user-io, basically the interface to control the settop box - The user-io can ...
0
votes
5answers
189 views

Race conditions in JVM languages versus C/C++

I was thinking about thread synchronization issues in compiled languages like C++, versus synchronization issues in languages like Java. I'm wondering how a JVM language like Java doesn't (at least ...
-2
votes
0answers
33 views

Help me fix my update function for projectiles. The bullet moves faster the closer xTarget - xPos is to 0 [migrated]

Here is all the relevant code. This gets run when the projectile is initialized: slope = (yTarget - yPos) / (xTarget - xPos); if (xTarget >= xPos) xDir = 1; else xDir = -1; if (yTarget ...
7
votes
5answers
710 views

Coding style issue: Should we have functions which take a parameter, modify it, and then RETURN that parameter?

I'm having a bit of a debate with my friend over whether these two practices are merely two sides of the same coin, or whether one is genuinely better. We have a function which takes a parameter, ...
3
votes
2answers
213 views

What's wrong with statically linking the STL into multiple shared libraries?

Here is the scenario: libA.so and libB.so both statically link to the same STL. libA.so has a public API that returns a std::string. libB.so calls this function and receives a copy of the string. ...
1
vote
3answers
224 views

Including extra headers that I do not really need

I always wondered what are the effects of including not needed headers to the final executable once compiled. In my code some times I may included many different headers that I do not need (or I used ...
3
votes
2answers
106 views

OOP CLI menu structure organization?

This problem has kept me from pursuing a project I'm working on because it influences the entire structure of the application. This question has been briefly touched on here, but I feel that it wasn't ...
-1
votes
1answer
64 views

Creating a new type of project file [closed]

I'm starting to work on a project where it would be quite useful to have something like a project file that holds all the data being used in a form that can't be opened/modified/used in anything but ...
23
votes
7answers
2k views

Is it good practice to rely on headers being included transitively?

I'm cleaning up the includes in a C++ project I'm working on, and I keep wondering whether or not I should explicitly include all headers used directly in a particular file, or whether I should only ...
0
votes
3answers
151 views

Store an object's name in the object or externally?

I'm in the process of building an application which needs extensive logging of points in time at which certain events happen. For example when it renders a sequence of different shapes to the screen ...
0
votes
1answer
116 views

Should I throw std::bad_alloc?

I am allocating memory on the stack, and distributing it manually to shared pointers. I end up doing something like this at startup (I've simplified it by ignoring alignment issues): char pool[100]; ...
0
votes
2answers
121 views

how to carry a specific number of significant figures while computing? [closed]

How to carry more or less than six significant figures (4 , 5 , 7.. ) in the computation while running a program ? i'm writing a program to solve a system of linear equations /using Gauss elimination ...
2
votes
2answers
164 views

How can I get better than O(N^2) space complexity for a type sequence search?

Suppose I have a type sequence through which I want to search: template <typename...> struct TypeSequence { using type = TypeSequence; }; I want to create a metafunction Search that returns ...
0
votes
2answers
418 views

Does any other language use the uniform initialization syntax found in c++? [closed]

Are there any other languages that use the new C++11 uniform initialization syntax thoroughly throughout the entire language, or is this entirely a C++ idiom at this point? I tried googling and ...
0
votes
0answers
71 views

In-place merging of sorted intervals in an array?

So I have code producing k sorted intervals in an n-sized array. What I'm brainstorming is the possibility of in-place merge of these intervals into a single sorted interval/array. The problem is ...
0
votes
3answers
111 views

Alternative to printing debug information to stdout\stderr [duplicate]

I currently have a long running application on an embedded Linux environment and all debug messages are currently being outputted to stdout using printf. This isn't ideal for special users who ...
-1
votes
1answer
76 views

Cross-platform CI builds [closed]

Does any Continuous Integration system out there offer building a project on several operating systems at the same time? Like, building the code on Windows, Linux, *BSD and OSX per commit? I ...
1
vote
0answers
65 views

Is conversion from C/C++ to Verilog/VHDL for FPGA a derivative work? [duplicate]

Say I have a C/C++ software licensed under GPL that gets converted into hardware design. By this conversion I mean that the exact functionality of the original software is being programmed into an ...
3
votes
2answers
321 views

How to avoid long call chains?

I have a hierarchy of objects, mostly connected by composition. I.e. (not showing the class methods for readability): class A {} class B {A a;} class C {B b;} etc... class Z {Y y;} class Z provides ...
1
vote
0answers
37 views

Qt: internationalization of images [migrated]

I am aware of utilities like GNU gettext for making the software multilingual. You give it a string id and it will return the translated string. But I also need this for images in Qt. For example, if ...
1
vote
2answers
136 views

Will there be a memory or processing time difference between a class member function and a global function

I'm writing a neuron network simulation program and every operation or additional byte per neuron scales insanely. I prefer C++ as a language over the others, but now I'm wondering if the class ...
0
votes
1answer
70 views

Extending a class for debugging: public API, hidden implementation or something else?

I'm working on a fairly large project that involves 3D drawing, and I want to add some visualizers (for example, to see the bounding boxes of the objects) to make debugging easier. However, I'm having ...
-2
votes
2answers
157 views

Why doesn't array declaration guarantee proper memory allocation whereas malloc does? [closed]

In C++, when I declare an array like int array[10];, it sometimes uses memory assigned to other variable where as this problem is non-existent when I use an integer pointer and malloc to allocate ...
3
votes
6answers
232 views

Explicitly define enum values, even if the default value is the same?

There are times when an enum's values are important: it is not necessary for them to be unique, they also need to have specific values. In such cases, should the values be explicitly defined, even if ...
5
votes
2answers
507 views

Robustness and pointer safety in C++

I'm currently building a server responsible of storing and managing few million records of fairly complex and interconnected data. For reasons beyond my control the work has to be done with C++. I ...
1
vote
2answers
275 views

What is the purpose of creating a member function with the same type as its class?

I'm sure I'll botch some of the specific terminology, but what is the difference between object and object2 in this implementation? Is the only purpose of the first method (prototyping the class's ...
1
vote
2answers
90 views

What is the name of a type that is defined from a template?

To give a complete example, let's say I have a template class that I now use to generate a type definition: template <typename T> struct A {}; using X = // I'm not asking about this ...
0
votes
1answer
99 views

Is there a good name for this pointer template? [closed]

I'm looking for a proper name of a class template with the following features: It's interface would look something like this, where Foo is a placeholder for the name I'm looking for. ...