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

learn more… | top users | synonyms

-2
votes
1answer
18 views

Reasons that debug symbols could change the application execution

The motivation for this question is that I'm in a situation in which I have to set up remote debugging for a multi threaded application running on a embedded device. C++ is the language. I've gotten ...
-2
votes
0answers
21 views

how to link boost thread with Xcode [on hold]

I have built Boost from the website using ./bootstrap.sh ./b2 install I think all are installed properly. I am trying to use Xcode to include the library of boost:thread.My code links to the ...
2
votes
3answers
174 views

Unit test private method in c++ using a friend class

I know that this is a debated practice, but let's suppose that this is the best option for me. I am wondering about what is the actual technique to do this. The approach that I see is this: 1) Make a ...
-2
votes
0answers
41 views

Code beautifier converting const int -> int const and training return type [on hold]

Is there any beautifier that can do more than just indent and add braces? I would like to convert C++ code to use the Type const style rather than const Type use C++11 trailing return types ...
0
votes
3answers
245 views

C++ Chess board design and smart pointers

I wrote a Chess engine in Java and I am porting it over to C++. I am new to C++. The idea: I have a Board object which holds a 2-dimensionnal array of Piece objects. Queen, Rook, Bishop, etc are ...
-3
votes
0answers
26 views

c++ Need help with arithmetic operations [migrated]

I need to make a program that basically reads the 2 numbers that the user inputs and then displays each number by adding, diving, subtracting, and multiplying it all at the same time. This is what i ...
-3
votes
0answers
55 views

Opinions on careers in mainframe systems? [on hold]

I'm still in school but I've had a chance to work with mainframes full time in a professional environment working with COBOL, JCL, Assembler (at school), mainframe extensions, all in all, I've been ...
-4
votes
0answers
42 views

Development and workings of DLL Injection [on hold]

I was planning on doing a thesis on DLL Injection and the social, and ethical impacts along with the technological side of it (how it works, example of it working) and I have created multiple ...
6
votes
4answers
490 views

Does internal state “leak” when it influences externally-visible behavior?

I have a method (in C++) which generates a value based on a parameter and the parameters from previous calls. Calling it more than once with the same parameter may generate different values each time. ...
2
votes
2answers
123 views

Decision making and maintenance

I'm trying to find an elegant way to implement a decision making algorithm that allow easy maintenance because the conditions for the decision making might change often. I'm going to try and be more ...
-3
votes
0answers
25 views

Screen capture technologies [on hold]

I want to write a screencasting program for the Windows platform, but am unsure of how to capture the screen. What technology to use. I gave a fair share of tries with C# and GDI+ but I can't get ...
-3
votes
0answers
25 views

Connect the database with c++ command line programs [on hold]

If somebody know the fortune program which is generally installed in Linux and Unix computer.So I want to know that how to read the data from database and whenever If i call my fortune program its ...
-1
votes
0answers
17 views

Discrepancy between Mathematica and Fortran expressions — Fortran gives wrong output (C,C++ programmer trying to use Fortran) [on hold]

I typically program in C or C++, but recently wrote some code in Fortran. I am worried that I've made a mistake in the Fortran code due to lack of knowledge of Fortran. I basically need to plot two ...
0
votes
1answer
89 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
vote
3answers
274 views

C++: Metaprogramming with a compiler API rather than with C++ features

This started out as a SO question but I realized that it is quite unconventional and based on the actual description on the websites, it might be better suited to programmers.se since the question has ...
-1
votes
0answers
60 views

Sharing dynamically allocated arrays between C++ source files [migrated]

I am trying to compile a code with two (more actually, but that is not important) source codes. In one of them I declared a variable size array like this: const int number_of_equidistant = ...
0
votes
3answers
245 views

Good 'real life' example of operator overloading C++ [closed]

What are examples of classes to use operator overloading on in C++? All the examples and tutorials I can find on the net use non-sensical classes/objects (foo/bar, one or two integers..) What are the ...
0
votes
2answers
128 views

How to organise and label methods, intended for debug?

I have a class System, which uses a bunch of other classes, to achieve a complex signal processing. In debugging System, one needs to observe the output signal for patterns. This is not achievable by ...
0
votes
0answers
83 views

c++ understanding size_t behaviour for vector creation [migrated]

this is a folow up to this c++ coding practice class vs. "free" functions question I posted a few day ago. In short, the idea is to create a custom vector class for statistical data ...
1
vote
4answers
377 views

How to work around Java's lack of pointers to pointers when working with linked data structures? [closed]

I've learned from a textbook how to implement binary search trees recursively in Java, and am working on implementing them nonrecursively. I've found a simple and elegant way to implement an insert ...
-7
votes
0answers
34 views

How can I set Visual Studio 2013 to run a compiled .exe with a modified PATH variable? [closed]

I made a .exe in Visual Studio 2013, and it has some files it depends on in the output folder. (an hlsl file, later there will be texture and audio file stuff). When I run it from visual studio it ...
-2
votes
0answers
59 views

C++/C++11 one-to-many multiplicity pattern [closed]

What are good patterns for representing one-to-many relationships between objects? Some possibly desirable features: Children only created through owning parent so that they are managed by parent. ...
2
votes
1answer
131 views

How do multiple levels of inheritance affect virtual function call overhead in C++?

I am considering using a class hierarchy with more than a single level of inheritance, where virtual member functions form a "chain", for example: struct Base { virtual void foo(); }; struct D1 : ...
3
votes
4answers
159 views

Storing a pointer to an argument passed by (non-const) reference

When designing an interface for passing objects which are meant to be stored for later use and which should not be 'null', I am always a bit uncertain if the argument should be passed by reference or ...
0
votes
2answers
126 views

Can I create a type, typedef or using statement that results in a different type if instantiated a second time or more?

Suppose I have a class that evaluates some computationally intensive function: class Value { private: int eval() { mCached = ExpensiveOperation(); return mCached; } static int ...
0
votes
0answers
36 views

API for accessing CTS and DSR signals of serial port

I'm trying to improve another abstraction of the serial port. The project involved often needs to check one of the single control signals CTS and DSR. This is currently done by a call to ...
0
votes
0answers
4 views

error LNK2019: unresolved external symbol? [migrated]

Firstly, I am beginner in c++ and Visual C++ (but not OOP). I am now trying to import Excel data to my data structure. What I have done is creating the structure(as class) in dataStructures.cpp along ...
-3
votes
0answers
34 views

Output of a program [migrated]

{ int a; a=4; cout<<a++<<++a; } The output of the above C++ program is 56 but why it is not 46 As a++ first print the value then increment a.
-1
votes
1answer
82 views

What are guidelines for a Win/Mac/Linux C++ source tree? [closed]

I'm learning C++ (C++11), specifically for cross platform game development using SDL. on Windows, I use Visual Studio 2012 (Considering buying '14' once it's out), on Mac OS X and iOS I'll be using ...
3
votes
2answers
250 views

Does ODBC require any run-time software beyond an .exe file to run against MySQL and ORACLE SQL? [closed]

I'm writing a software [under Windows] in C++ which later needs to be able to connect to both MySQL and ORACLE SQL. Now the software needs to be as simple for the user as possible. Now I'm ...
-2
votes
0answers
139 views

How to call a function with argc & argv? [migrated]

I'm currently trying to create a GUI for an existing command line program using QT, as a learning exercise. The original code was written in c, and I have included the c wrapper for the c++ bit. I ...
1
vote
4answers
440 views

c++ coding practice class vs. “free” functions

I am currently writing my first bigger project in c++. Its basic linear algebra. I am aware that boost libraries and others exist, but for various reasons I need to write my own. Purpose of the ...
0
votes
0answers
42 views

c++ coding practice class vs. “free” functions [duplicate]

I am currently writing my first bigger project in c++. Its basic linear algebra. I am aware that boost libraries and others exist, but for various reasons I need to write my own. Purpose of the ...
6
votes
4answers
446 views

Undefined behavior, in principle

Whether in C or C++, I think that this illegal program, whose behavior according to the C or C++ standard is undefined, is interesting: #include <stdio.h> int foo() { int a; const int ...
1
vote
1answer
84 views

Standardization and official guidelines for C++ template parameter naming [closed]

What are some explicit and official guidelines or standards for template parameter naming in C++? I've done something like this in the past: template<typename TContainer, typename TKey> void ...
0
votes
0answers
60 views

how to do vector ops on a “vector <string> item” C++ [migrated]

I am trying to work on an array of strings (char **) where I am trying to use the C++ paradigm of "vector device_names". After parsing an input string for matching pos/neg entries, I want to sort ...
1
vote
3answers
170 views

Is it bad practice to use Inheritance to associate methods with a basic container?

Basically, I have code that looks like this. It's a typedef and a set of methods that revolve around that typedef. class foo { // Foo stuff... // Registration Stuff private: ...
1
vote
0answers
53 views

Function pointers to object instance returned by function pointer [migrated]

Im new to c++. I want to make a std::map with strings of get-method names mapped their respective get-method. These are to be looped over and present the value obtained by the get-methodtogether with ...
1
vote
1answer
114 views

C++ : Association, Aggregation and Composition [closed]

I'm beginning to study OOAD and I'm having difficulty finding a C++ code example that'd illustrate how Association, Aggregation and Composition are implemented programmatically. (There are several ...
4
votes
2answers
264 views

dealing with a very large state machine in a class

I am currently implementing a class for a network protocol. The protocol uses a quite complex and extensive finite state machine. A pair of an event plus a state is mapped to a function, which does ...
1
vote
2answers
128 views

How to abide the “allocate in caller” rule when the size is computed in the callee?

Let's say we have an opaque type handle_t that is managed through a simple interface with functions such as: handle_t *handle_init(void); int handle_do(handle_t *); void handle_free(handle_t *); ...
0
votes
0answers
13 views

On linux, how to get “incompatible” i386 f77 libraries to work with current Fortran compilers, like gfortran? [migrated]

I would like to run the elf32-i386 library libkernlib.a with a Fortran 77 program on my latest Ubuntu linux machine. From what I've read, gfortran is backwards compatible with Fortran 77, but I'm ...
0
votes
0answers
20 views

Port forwarding and C++ Winsock Client-Server applications [migrated]

As the title says, I'm creating a TCP client and a server program in C++. My question is, when running the client and server on two separate machines that go through a different firewalled router over ...
0
votes
1answer
174 views

Polymorphic engines in C and/or C++ [closed]

I stumbled across polymorphic engines and I don't know anything about them. However, I am curious about how they are written. Every example that I've looked up writes them in assembly, my assembly is ...
-3
votes
2answers
106 views

Why friend in C++ should be in the header file? [closed]

Friend function/class, FriendOfX for some arbitrary class X is an implementation detail of class X. Why in C++ we have to declare them in the header file? Are there any compelling reasons to make this ...
-7
votes
3answers
113 views

What's the list of how to precisely talk about problems in C++ code within the spec? [closed]

The C++ specification leaves a lot of leeway such that when you write bad code, compiler authors are not responsible for defining a specific mode of failure. We know of course that is Undefined ...
-3
votes
1answer
115 views

Is this a good use of a base class? [closed]

I am developing some HW drivers, which access registers. I have a few classes, for example. ClassRegisterBlock1, ClassRegisterBlock2. In each of these classes, they define the bits to manipulate, ...
0
votes
0answers
71 views

initializer_list combined with other parameters [migrated]

Suppose I have a class which takes a parameter of type T and a collection of parameters of type U in the constructor. The following solution works: struct Q { Q(T t, ...
2
votes
1answer
200 views

Any OOP design pattern that is somewhat representative of all of the SOLID OOP design principles at play?

I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one ...
1
vote
2answers
217 views

How to avoid redundant code in designing inheritance in C++

Say I have a Base class called Car and it has 3 derived classes say Ford, Honda and Audi. The issue is, all three derived classes have exactly same code but minor difference in calling member ...