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

learn more… | top users | synonyms

5
votes
2answers
467 views

Deploying Qt-based app on Mac OS X

I wrote a cross platform application and I distributed it successfully for Windows and Linux (and tested them on "clean" virtual systems, with no other additional software and/or libraries installed). ...
0
votes
1answer
46 views

Are there real world examples demonstrating reasonable performance improvement by using move semantics?

(I've asked a similar question on SO but unfortunately it might not be proper, so I also put here; please kindly point out if you think it's a duplicate.) I've heard many words about the move ...
-1
votes
2answers
112 views

Mermaid problem (OOP)

A Mermaid is half fish and half human. It has upper human body and lower fish body. When under water its upper part swims like a human while its lower part swims like a fish. Please explain how can it ...
1
vote
4answers
666 views

Should non-interface code be hidden from the client?

I am working on a library which had several headers that are meant to only be used by the library itself. I also have a few classes and functions in headers that I do not want the client to use. For ...
1
vote
2answers
233 views

In C++, should I ever declare a local variable in the corresponding header?

So for example, I create a class with two functions: foo.h class foo { public: foo(); void bar(); void ey(); bool m_memberBool; bool localBool; // ??? Should I put this here? }; ...
32
votes
6answers
12k views

Why is there no 'finally' construct in C++?

Exception handling in C++ is limited to try/throw/catch. Unlike Object Pascal, Java, C# and Python, even in C++ 11, the finally construct has not been implemented. I have seen an awful lot of C++ ...
-1
votes
1answer
40 views

One symbol - one meaning?

It's well known recomendations that: 1) class or function should have one responsibility 2) variable should not be reused in different contexts We can generalize this recomendations to general ...
4
votes
5answers
340 views

Structuring Procedural vs OO code

I have spent the vast majority of my programming career using Java and very OO based C++. I am really interested in learning to think more procedurally, so I have been starting to do some practice ...
0
votes
1answer
138 views

Estimed number of tries

Problem: The Oscar Committee wants to decide which person should get the best actor award among the given N actors.For that they decided to use a random function random_bit() which returns either 0 ...
-1
votes
1answer
189 views

Optimal movie schedule

Let's say Mr. A goes to cinema and he gets a movie schedule. There are N movies on the program today (1 < N < 50) and for every movie the time of the start and the time of the end are given in ...
7
votes
4answers
763 views

Apple eating problem

Player A and Player B play a game. On the middle of the table there is a pot full of N apples of different weights. Player A starts first and choose an apple and start eating it. Losing no time player ...
2
votes
1answer
1k views

How is C++ in QT different from the standard C++ libraries?

I want my app to be able to manipulate images and create watermarks and also needs to run on both windows and mac. Hence I've been investigating QT. Does QT ship with all the libraries I will need to ...
1
vote
0answers
58 views

Is the behaviour of floating-point arithmetic defined by the c++ standard?

I started writing this as a SO question but I think it's better suited here. While I'm happy for simply an answer I'm also fond of the "Teach a Man to Fish" phylosophy so I'm happy for people to point ...
0
votes
1answer
456 views

Reading a character from a file stream in c++ (AKA: Why no C++ standard equivalent of old conio.h)?

This is a question of about design decisions. I find that there are so many different things I work on where reading a _kbhit() is amazingly useful but I can't find (read: there isn't) any ...
9
votes
4answers
725 views

What features did c get from c++? [on hold]

What features were added to C that were originally in C++? When where they added and for what reason(what where the pro/con arguments)? How do they differ in C as compared to C++? Did the features ...
0
votes
1answer
381 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
34 views

keep getting wrong answer on uva 1585 score [on hold]

There is an objective test result such as "OOXXOXXOOO". An 'O' means a correct answer of a problem and an 'X' means a wrong answer. The score of each problem of this test is calculated by itself and ...
-2
votes
0answers
20 views

Can anyone tell me what will be the better for Http proxy [on hold]

I have assignment based on computer networks I have to design a Http Proxy Server but I am confused that whether I should build it on java or C#. Please guide me and also explain why it is good ...
2
votes
0answers
61 views

Can't figure out class scheduling issue? [on hold]

"You are a college advisor trying to help students plan their academic careers. You have the list of courses in each major and their prerequisites. Students often want to take their major courses as ...
-1
votes
0answers
63 views

How do you recognize when topological sort shoudl be used? [closed]

What are the general properties of a programming problem that hint to the necessity of topological sort?
-1
votes
0answers
88 views

I study c++ constantly but no idea to make [closed]

Hi I'm student in highschool. My favorite language is C++ and I love it. And I try to study alot(recently reading EMC++ or template or else) I want to make some program but have no idea what to make. ...
12
votes
4answers
9k views

In C++ why and how are virtual functions slower?

Can anyone explain in detail, how exactly the virtual table works and what pointers are associated when virtual functions are called. If they are actually slower, can you show the time that the ...
16
votes
8answers
1k views

How to spread awareness for generic programming among team members?

I am staying in an environment, where people believe: Java generics are the feature exclusively used for library writing and not for the real coding. C++ is an OO programming language; template is ...
33
votes
17answers
6k views

Teaching C++ to first time high school students: Where to draw the line?

I will be mentoring a team of high school students for the FIRST Robotics Competition, most teams here develop[ their robot software using C++. For many of the students on the team this will be their ...
3
votes
2answers
231 views

How to iterate through all permutations of valid links between nodes

Imagine a 2D area, with a number (array) of nodes (or points) defined within it, in arbitrary (but known) positions (integer x,y coordinates), like this: From there I want to be able to, ...
0
votes
1answer
75 views

Receiving information from another application [closed]

I am currently attempting to create an AI which can play games, but learns to play rather than using hard-coded instructions. But, this isn't my problem, my problem is telling the AI whether it has ...
1
vote
1answer
76 views

Run a c++ program under lots of different data maps

I want to run a c++ program to process a lot of data from different xml files and output results. I run the program once per file and potentially have around 50 different files. The trouble is each ...
0
votes
0answers
16 views

Calling functions in C++ function is of non-class type [migrated]

I am very new to programming, especially in C++, and am trying to build my first project on my own. A budget program. Criticism is welcome. I'm using a constructor in my main file to call my functions ...
5
votes
2answers
263 views

Transforming XML to JSON in C++

Working with XML in C++ seems a bit of a pain and I'm looking at a way to output JSON. I've stumbled on two different approaches: A) XSLT transformations: ...
-6
votes
0answers
79 views

I am new to programming,recommend books and topics to cover to become a better programmer [closed]

I am 18 and started coding now which I really feel is late,coming to the topic.I just quit my college I am interested in creating bots,forums and website building and even building Android and I phone ...
0
votes
1answer
95 views

Moving from C++ to NodeJS - Working with XML and JSON

I need to make a program to compare several large +100MB XML files, find the difference, and spit out JSON. I have written the comparison code in C++ and it performs great but now when I am getting to ...
-3
votes
1answer
82 views

I want to know how to code graphics in c++ [closed]

It doesn't matter what graphics. Just some that could work for the compiler code blocks 8.1. #include <graphics.h> This graphics.h Sounds good but I don't know how to use it. Help would ...
-4
votes
1answer
41 views

C++ how export variable from a dynamic library? [closed]

I have an API class: API.hpp (public API) class math { static __declspec(dllexport) double Pi; static __declspec(dllexport) double Sum(double x, double y); }; Dll.cpp (test.dll) ...
-3
votes
0answers
34 views

Text UI strategy game: Which Language/engines? [closed]

I'm thinking about building a simple 2d strategy game, the likeness of starcraft, except extremely simplified. The main thing I want to do is have a text UI, the kind of thing you see when you ...
2
votes
1answer
88 views

How minor of a case is a class appropriate for?

I'm trying to use composition in an Entity class of mine. So far, an Entity "is" Displayable(inherited an ABC), and "has" a Position(contains a point-like class). I know I will want my Entity to ...
4
votes
2answers
162 views

Is there any harm in having classes made up mostly of inherited classes?

Say I have a few base classes: HasPosition supplies a 2D location, and methods to "move". IsDisplayable defines how a class will be displayed in a given graphics library (say, curses), and methods ...
16
votes
8answers
909 views

Is directly using Make considered obsolete?

So I have been coming across many comments/posts/etc regarding creating makefiles directly, and how it is a silly thing to do in 2015. I am aware of tools such as CMake, and I actually use CMake quite ...
5
votes
2answers
178 views

Designing exception classes

I'm coding a small library and I'm having some trouble with designing the exception handling. I must say that I am (still) confused by this feature of the C++ language and I tried to read as much as ...
1
vote
5answers
364 views

How to share memory between applications written in C/C++

I'm going through a program written in C/C++ for control in robotics. Basically, three different programs run at the same time, and they communicate via shared memory. Google-ling around I found ...
156
votes
9answers
11k views

Why do many exception messages not contain useful details?

It seems there is a certain amount of agreement that exception messages should contain useful details. Why is it that many common exceptions from system components do not contain useful details? A ...
0
votes
1answer
494 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 ...
10
votes
8answers
8k views

c style casts or c++ style casts

So, what do you use? int anInt = (int)aFloat; or int anInt = static_cast<int>(aFloat); // and its brethren And, more importantly, why?
2
votes
3answers
261 views

Repetitive code over multiple classes. Best way to centralize code?

I'm working with 3D arrays that I flatten into a 1D arrays with the following index calculation: index = x + WIDTH * (y + DEPTH * z) I'm starting to notice that I'm using the calculation all over ...
49
votes
13answers
3k views

Philosophy behind Undefined Behavior

C\C++ specifications leave out a large number of behaviors open for compilers to implement in their own way. There are a number of questions that always keep getting asked here about the same and we ...
-3
votes
0answers
37 views

3-Tier architecture - Object Relation [on hold]

I have some question about the 3-Tier architecture : Relation between Business Object and Manager If my master object (example : character) have a relation with another object (charater_stat, ...
0
votes
0answers
55 views

Matching groups of similar lines on a generic matching algorithm

I have to write a program to search through a file containing lines and find lines that match to a degree of tolerance but are not necessarily the same. So for example the following lines would match: ...
3
votes
3answers
339 views

No exceptions C++ and partially constructed objects

Looking over Joint Strike Fighter Air Vehicle C++ Coding Standard, rule AV 73 states something on the lines: Default c++ constructors should be avoided if that means leaving object in a partially ...
2
votes
1answer
208 views

How can C++ make it possible to use dynamic container classes even in embedded systems?

How can C++ make it possible to use dynamic container classes even in embedded systems? Background info: I've been working with PIC (C) and AVR (C++) processors and at the moment (PIC C) I'm ...
3
votes
3answers
336 views

Where should I place a typedef when used in method signatures in C++?

I'm using an Optional class quite similar to that of boost. For semantic reasons, I switched an attribute of the same (structured) type in some class definitions (and therefore also in method ...
-1
votes
0answers
22 views

Programming with Kinect on Ubuntu Linux [migrated]

first time asking a question here so please bear with me if I'm not entirely coherent. I've been attempting to learn how to use the OpenNI, libfreenect, and SensorKinect libraries to create some code ...