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

learn more… | top users | synonyms

0
votes
1answer
37 views

What is `using namespace` pollutuion?

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? ...
0
votes
0answers
15 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 ...
0
votes
0answers
29 views

Splitting and hiding headers in a static library

I am writing a static library for C/C++ (personal project). As my headers became rather large, I thought that splitting my headers would be a good idea. Right now a header looks like this: ...
3
votes
2answers
83 views

How to manage memory in C interface for C++ implementation considering c++11?

I have a library implemented in C++ which has a C interface. This C interface is, for all intents and purposes, the only way to use this library. C++11 seems to discourage the use of raw pointers but ...
-1
votes
1answer
27 views

How do I save and load a std::string with object serialization in C++?

I had something simple like this POD structure... struct Actor { string name; int hp; }; Later on, for simplicity sake here, I saved the structure to file using... ...
0
votes
1answer
38 views

How to make C++ template stack work with basic data types and compound variables?

Templates are nice for similar algorithms of different data types. Say I make a template stack of a basic data type... Stack<int> stck(10); stck.Push(5); I'd pop it... int x = stck.Pop(); ...
-5
votes
0answers
18 views

Closing MessageDialog windows with a timeout [on hold]

GTK - GTKMM In gtkmm messagedialog, How do I set a timeout handler to activate the OK button in the dialog window. I have a timer which counts down in seconds but when it reaches 0 it just hangs. The ...
9
votes
4answers
590 views

Which one of these answers regarding functions is incorrect?

So while I've been doing some lengthy compiles I decided to take the C++ general test on ODesk and came across this question. If I'm not mistaken, given the wording (or lack thereof) all of these ...
-5
votes
0answers
44 views

What language is this? [on hold]

import bz2,struct,os,stat from cStringIO import StringIO sfai=file('dfdata.sfai','rb') h=struct.unpack('128L',sfai.read(0x200)) assert h[0]==0x49414653 # "SFAI" start=h[6] size=h[7] print "INDEX: ...
3
votes
1answer
63 views

In c++, difference between linking a class object and just including it.

this is my first time here. I'm a physics grad student and I've recently found a research group to work with. We study statistical mechanics using computer models, so there is a significant ...
0
votes
1answer
162 views

Does it make sense to choose UTF-32, based on concern that some basic rule will be broken for UTF-8?

I'm working on an cross platform C++ project, which doesn't consider unicode, and need change to support unicode. There is following two choices, and I need to decide which one to choose. Using ...
-1
votes
0answers
56 views

Linear Algebra Api for c++ using external memory [on hold]

I need to perform Linear Algebra operations on Large size vectors and matrices which might or might not be sparse. Operations better include LU Factorization for matrices in addition to the basic ...
0
votes
2answers
197 views

Can this argument be enough?

We have two C++ classes named Important and Small The class Small use a few methods and attributes from the class Important, but not all. Since our application is performance critical, instead of ...
-1
votes
1answer
90 views

c++ : Fast searching in 2d array [on hold]

I have a 2D array which I use in my code in the following way: Searching for a particular entry takes lot of time whereas I want to reduce the time for searching elements. Can anyone please suggest ...
-3
votes
0answers
39 views

Data streaming C++ library? [closed]

I'm looking for a C++ library that implements a C#'s Stream-like interfaces over several common data tasks. So I need data compression, encryption, base64 conversion, file I/O to be implemented as ...
2
votes
2answers
159 views

Testing abstract class' behavior

I'm currently refactoring an existing design, which was created without TDD. There is a class hierarchy with one abstract base class and two subclasses. In the original design, these classes were ...
-1
votes
0answers
46 views

How Do I build a Custom Web Browser Using Webkit? [closed]

This is my first post, so please bear with me. First, though, let me introduce myself: My name is Jessica and I am 30 years old. :-) I want to build a custom Independent webkit based tabbed web ...
0
votes
0answers
22 views

How to declare two dimensional array accessible from other functions? [migrated]

I have a quick Question: If I want to have a two dimensional array accessible from other functions, should I define it as a static ? and If so, How can I initialize it using other members. Here is ...
-5
votes
0answers
63 views

Problem with this program? [closed]

Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square ...
-3
votes
0answers
46 views

C++ Book to read after Accelerated C++ [closed]

This question has not been asked but: i have read accelerated C++ twice and i am quite good at the C++ abstractions What book should i read next any suggestions Accelerated C++ was only 350 pages ...
10
votes
3answers
598 views
+300

What is the pattern for a safe interface in C++

Note: the following is C++03 code, but we expect a move to C++11 in the next two years, so we must keep that in mind. I'm writing a guideline (for newbies, among others) about how to write an ...
-1
votes
0answers
60 views

Starting off Game Development from…where? [closed]

Does the gaming development community here have any suggestions for future game developers on how to begin programming ... games? I personally would think people would start off with 2D then start 3D ...
-4
votes
0answers
57 views

C++ problem about & operator [closed]

And this code burnt my head alot ; const int kHashMask = 0x7FFFFFF; int hashCode(TBEdge e) { return (hashCode(e.start) + kLargePrime * hashCode(e.end)) & kHashMask; } 1) ...
-1
votes
0answers
11 views

Finding in std::list [migrated]

Tell me please how to do that the best using STL. I have class that has a member std::list. It's private member. I have only const_iterator to begin and end. I'd like to check if list has some ...
1
vote
4answers
232 views

Wrapper around C++ STL

Where I work we have our own system library, which pretty much is only wrappers around the STL, such as: template <typename T> class HVector { protected: std::vector<T> data; public: ...
1
vote
1answer
126 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 ...
-1
votes
2answers
64 views

What is a simple explanation for the reinterpret_cast expression? [closed]

I see that it is a compiler directive which instructs the compiler, but what does that mean?
0
votes
1answer
97 views

Do C++ library developers only write C compatible interfaces as an afterthought? [closed]

I have developed the distinct impression that although C++ libraries are often developed for other slower languages to link with when performance is needed, some feature known as name mangling and ...
-4
votes
0answers
53 views

Can I get right guidance to enter software development? [closed]

I am beginner in software development As a beginner I know C/C++ not at expertise level But I am liking Python Give me right guidance
-2
votes
0answers
30 views

Is there a way to initialize a container with one line? [migrated]

I am looking for vanilla C++89 solution (no boost, or qt, etc.) Is there a way to do something like this : // valid in c++ 11 std::vector<Foo> vFoo {Foo1, Foo2, Foo3, Foo4} ; or something ...
-2
votes
0answers
94 views

Is there any other way to run .exe from Java? [migrated]

The main problem is that I cannot run my c++ logic by running it through Java; am I creating a subprocess properly? Thank you all; --- UPDATE! --- So I have written these to test the ability to open ...
-4
votes
0answers
24 views

I have a class that is derived from a QList object. I have used for loops, I keep getting the error that list is not declared in the scope [migrated]

I have a class that is derived from a QList object. I have used for loops, I keep getting the error that list is not declared in the scope #include "AssetList.h" #include "Asset.h" ...
1
vote
0answers
57 views

Guideline for managed (C#) and native code (C++) hybrid development [closed]

Is there any guideline for a mixed managed and unmanaged system architecture? Given the same amount of time I find managed code to give better performance. The default to pass by (constant) ...
-2
votes
1answer
111 views

Use cases for C++ in native mobile applications (iOS, Android, Windows Phone) [closed]

I am working on an project which permits to order, select recipients and pay products from mobile applications on Android, iOS and Windows Phone 8. I wish to avoid rewriting code between each ...
1
vote
3answers
319 views

Should I pass array or pointer?

I am writing a C++ library (but prefer C style interface functions) and one of the function returns array of floats. I am not sure if I should pass pointer or fixed array to get this data? // in the ...
0
votes
2answers
105 views

Characterization in Testing: Unit test or Functional test [duplicate]

So I'm trying to push for more automated testing in my company, which focus a lot on prototype and proof of concept systems. We currently use Google Test for unit testing. This tests specific test ...
1
vote
2answers
84 views

Initialization of objects in a system using dependency injection

This is a follow up question to the following post: Injecting dependencies (DI) in c++ applications In a system that uses DI, someone, somewhere should be responsible to create the various objects ...
2
votes
2answers
148 views

Injecting dependencies (DI) in c++ applications

I am playing with dependency injection, but i am not sure I am doing it right. Especially, I am not sure what should be the correct way to build classes with injected dependencies. Say I have a class ...
24
votes
5answers
3k views

Why is it bad to write something in language X as if you're writing a program in language Y in terms of using a shared coding paradigm [closed]

A while ago, I asked a question on SO about something written in C++, but instead of getting an answer to the problem at hand, the comments went all crazy on my coding style, even when I indicated ...
0
votes
2answers
49 views

Mutable cursor in readonly object?

I've been searching for the different uses of the keyword mutable. I've found that it is generally used for caching, lazy computing, mutex, ... But I'm wondering if it is coherent to use it for a ...
0
votes
1answer
76 views

How to use namespaces to separate interface from implementation, in c++?

As far as I can tell, you can make your interface known to others by providing your .h file. Your .cpp is the implementation. Then they can see the function names, the parameter types, the return ...
0
votes
2answers
179 views

What's a DRY alternative to c++ header files? [duplicate]

In c++, is there any other way, besides header files, to use a function defined in file A.cpp, inside file B.cpp that would be considered good programming practice?
0
votes
1answer
127 views

How to reuse c++ code? [closed]

How do I call functions defined outside a source file given you shouldn't use header files? -- EDIT: generic(?) question below So, first, a problem should be broken down into simpler subproblems. ...
1
vote
4answers
214 views

How do you call one program from another?

What I'm wondering is how running programs communicate with each other, and if someone could post some sample code for how to do this, so I can try it out myself, just for educational purposes. For ...
-1
votes
1answer
67 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 ...
41
votes
10answers
4k views

Is better Show() + Hide() or SetVisible(bool visible)?

What is better and why? (From interface-design point of view) : a) To have two Show() and Hide() functions b) To have one SetVisible(bool visible) function EDIT: For example some object have ...
0
votes
1answer
81 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 ...
0
votes
3answers
249 views

Print bottom view of a binary tree

For a binary tree we define horizontal distance as follows: Horizontal distance(hd) of root = 0 If you go left then hd = hd(of its parent)-1, and if you go right then hd = hd(of its ...
3
votes
2answers
196 views

How to find number of points with same minimal distances on matrix

I'm trying to find the number of points in a matrix with the same minimal distances. Start with a MxN matrix, where M and N < 50000. There is given a set of fixed points, with their respective ...
1
vote
2answers
147 views

Is it a good practice to choose the highest warning level in C++ programming? [closed]

I used to select the default warning level in C++ programming. For example, in VS, the default warning level is Level3 (/W3) and No (/WX-) (don't treat warnings as errors). I am wondering is it a ...