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

learn more… | top users | synonyms

-3
votes
0answers
32 views

Using Turbo C++ For OS Development [on hold]

I am working with operating systems , i have gone through several books , even osdev website but it is written that GNU is the latest compiler and best option for developing operating system . Now the ...
3
votes
4answers
280 views

Organise C++ classes around SQL database

My question is about how best to organize C++ classes around a database model, and I understand this may appear very elementary. The software I propose to create will do the following. It is intended ...
-1
votes
3answers
120 views

Objects in smalltalk and c++ [on hold]

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++?" ...
5
votes
3answers
334 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
2answers
245 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
0answers
78 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 ...
0
votes
1answer
223 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 ...
-4
votes
0answers
40 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 ...
-1
votes
5answers
539 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) { ...
-2
votes
0answers
41 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.
3
votes
5answers
1k views

What is “using namespace” pollution?

I was looking at the google coding guide [here] and they do not recommend that one use the using namespace ornamespace:function` - if I did not misinterpret it. Does this apply to std as well? ...
1
vote
1answer
696 views

How to break these long C++ lines in a neat way? [closed]

I'm on my first bigger C++ project and find that I have some really long lines. My goal is to break them to 79 columns, but I do not really know how to do this in a neat way. Are there some guidelines ...
-3
votes
1answer
94 views

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

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
vote
4answers
262 views

Application qos involving priority and bandwidth

Our manager wants us to do applicaiton qos which is quite different from the well-known system qos. We have many services of three types, they have priorites, the manager wants to suspend low priority ...
-1
votes
0answers
43 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
92 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 ...
24
votes
10answers
8k views

Why are pointers not recommended when coding with C++

I read from somewhere that when using C++ it is recommended not to use pointers. Why is pointers such a bad idea when you are using C++. For C programmers that are used to using pointers, what is the ...
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 ...
-2
votes
0answers
63 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. ...
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) ...
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" ...
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 ...
4
votes
2answers
567 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 ...
-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 ...
4
votes
1answer
268 views

Move semantics in C++ - Move-return of local variables

My understanding is that in C++11, when you return a local variable from a function by value, the compiler is allowed to treat that variable as an r-value reference and 'move' it out of the function ...
0
votes
1answer
326 views

Interface questions for using Command Pattern and Dependency Injection together

I have many projects that have essentially the same high level requirement: test all hardware on a device. Each device can have a different communication protocol, requires different test equipment to ...
3
votes
3answers
308 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 ...
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 ...
0
votes
1answer
167 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 ...
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 ...
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 ...
-1
votes
1answer
182 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
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 ...
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 ...
7
votes
5answers
711 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, ...
1
vote
1answer
242 views

Creating a custom GUI. App/DE/WM?

I am starting with this project of mine of writing a custom UI for linux. What would happen is: The computer would boot into this UI which would not be the typical taskbar/icons/startbutton kind of ...
17
votes
3answers
2k views

How to solve the problem of nested comments

It appears in not just one language that comments can't be nested. Do you have a good solution for this problem? One workaround in C/C++ and Java is to only use the single-line comment but it becomes ...
-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 ...
1
vote
3answers
225 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 ...
5
votes
3answers
3k views

Whether to use -pedantic flag in g++ or not?

I'm learning C++ and I'm using g++ on Linux for practicing. I want to know if people working as programmers use g++ -pedantic flag and also its importance in real world. What about other compilers, ...
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. ...
8
votes
5answers
7k views

Why can you have the method definition inside the header file in C++ when in C you cannot?

In C, you cannot have the function definition/implementation inside the header file. However, in C++ you can have full method implementation inside the header file. Why is the behaviour different?
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 ...
-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 ...
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 ...
1
vote
1answer
61 views

saving connectivity information in a nodes/edges network

I want to implement the A* algorithm. I have a network with Nodes and Edges, both are classes. Now, I am unsure how to approach the connectivity information. Should a node know which edges depart ...
0
votes
1answer
117 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]; ...
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 ...