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

learn more… | top users | synonyms

0
votes
0answers
28 views

Linear Algebra Api for c++ using external memory

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 ...
1
vote
2answers
117 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 ...
6
votes
2answers
428 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 ...
3
votes
2answers
188 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
votes
1answer
84 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 ...
136
votes
15answers
63k views

When to use C over C++, and C++ over C?

I've been introduced to Computer Science for a little over a year now, and from my experience it seems that C and C++ are both considered to be "ultrafast" languages, whereas others such as Python and ...
0
votes
1answer
326 views

Good practice using signals and event driven system

I am using signals (specifically Boost signals2) to create an event driven protocol API and model. Most elements have their own signals, and there are usually multiple of each element. Consider a ...
78
votes
15answers
7k views

Why did memory-managed languages like Java, Javascript, and C# retain the `new` keyword?

The new keyword in languages like Java, Javascript, and C# creates a new instance of a class. This syntax seems to have been inherited from C++, where new is used specifically to allocate a new ...
-3
votes
0answers
38 views

Data streaming C++ library? [on hold]

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 ...
1
vote
0answers
91 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
43 views

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

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 ...
0
votes
1answer
555 views

Is this proper OO design for C++?

I recently took a software processes course and this is my first time attempting OO design on my own. I am trying to follow OO design principles and C++ conventions. I attempted and gave up on MVC for ...
-5
votes
0answers
63 views

Problem with this program? [on hold]

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
42 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 ...
-1
votes
0answers
58 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
55 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) ...
-4
votes
0answers
52 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
1
vote
4answers
224 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: ...
-2
votes
0answers
26 views

Vector iterator not dereferencable [closed]

In my code I have here, it is supposed to iterate through a vector using an iterator, and it works for one loop, but when it comes around again to check if temp->mParent == nullptr, it complains that ...
-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 ...
-2
votes
0answers
37 views

What is better for opencv? C++ or Java? [closed]

In terms of speed, ease, applicability, and so on; which has the most potential of the two? From a scalability factor, I don't want something that has boundaries or will cease from lack of support ...
1
vote
1answer
121 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
62 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
92 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 ...
0
votes
0answers
79 views

How to integrate an existing compiler like gcc in my C/C++ IDE? [closed]

I intend on developing a very simple IDE for C/C++. It will be written in C++ using Qt, or if required I can migrate to another IDE like MonoDevelop. The IDE can be better called an editor+compiler, ...
5
votes
4answers
1k views

Learning C for C++ programmers [closed]

That's right, I learned to program in C++, and of course know the common set of features of both languages, so I can program in C. But I'd really like to read tutorials or books that teach you C, and ...
-1
votes
4answers
2k views

Can I change operator precedence and associativity in C++?

As the title says, I find it useful to be able to overload operators. Is it possible to also change the way the operators are parsed by specifying the precedence and associativity of overridden ...
1
vote
2answers
117 views

How to manage focus for a small set of simple widgets

I'm developing a set of simple widgets for a small (128x128) display. For example I'd like to have a main screen with an overlay menu which I can use to toggle visibilty of main screen elements. Each ...
-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 ...
0
votes
1answer
210 views

What data structure is suitable for implementing dynamic huffman encoding and decoding on a piece of text?

Some pseudo code or resources will be appreciated.I was thinking if implementing it in form of a BST stored in an array. However,not all operations can be performed easily using this approach. I am ...
-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" ...
-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 ...
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
108 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
318 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
104 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 ...
2
votes
2answers
147 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 ...
2
votes
1answer
198 views

Why function returning by Address can not be a Lvalue?

Why it is not possible to make it LValue if a function return by address (while possible in case of reference)? int* returnByAdress() { int x =20; return &x; } int& ...
23
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 ...
1
vote
2answers
83 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 ...
0
votes
2answers
48 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 ...
-6
votes
3answers
277 views

Is solving these kind of problems really important in programming? [duplicate]

We're learning C++ at school. We are studying loops for, while, etc.... We always keep having questions like: Make a program that gets the next output and uses a for loop. 1 3 5 7 9 11 Would it be ...
0
votes
1answer
74 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
149 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 ...
10
votes
6answers
3k views

Is “Explain the RAII idiom” a good C++ screening question? [closed]

A company that I work with has asked me to do candidate phone screenings to make sure they aren't completely embarrassed when sending over someone to a potential client. It turns out that a fair ...
0
votes
2answers
177 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
126 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. ...
12
votes
6answers
1k views

Are header files actually good?

I find header files to be useful when browsing C++ source files, because they give a "summary" of all the functions and data members in a class. Why do so many other languages (like Ruby, Python, ...
0
votes
3answers
248 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 ...