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

learn more… | top users | synonyms

-5
votes
0answers
12 views

C++ I'm a bit stuck on what I did wrong [on hold]

//Write a program that calculates and prints the final value of a ten year, $10,000 //investment whose annual return gradually declines from 2% to 1% over that term. #include <iostream> using ...
-1
votes
1answer
35 views

Is visual c++ cross plat

Is VC++ cross platform? If, not how can i make it. Should I just use code blocks for cross platform and include any needed dlls in the project? I'm using OpenGL and need to make my game supported for ...
0
votes
2answers
27 views

Making effective use of SIMD instructions without moving whole app to c++

I want to use SSE2 or similar instruction sets for simd to improve performance in my application. My situation is this: I've written some code for the app in c# but I don't mind porting if it's ...
0
votes
1answer
78 views

How can frond-end developer support different encoding (UTF-8 , UTF-16,..)other than ASCII?

I'm writing simple language compiler frond-end (based on LLVM) in C++, and I wonder how could language support encoding stuff? How can I (as compiler writer) support encoding? I need to know the ...
-3
votes
0answers
53 views

C++ Objects created on heap [on hold]

#include <iostream> using namespace std; class Test { public: Test(int i) {x=i;} int GetX() { return x;} private: int x; }; int main() { int p, counter = 1; do { ...
0
votes
0answers
23 views

memory corrupted using std::vector in constructor [migrated]

Given an array of strings, I am writing a class to separated them into different groups according to their length, i.e. the ones of same length goes to the same group. The number of groups and the ...
-4
votes
0answers
32 views

Is there any problemin my program below? [on hold]

#include<stdio.h> #include<conio.h> int main(void) { int num,i,p; printf ("enter no"); scanf("&d",&num); p=1; for(i=2;i<=num/2;i=i+1) if((num%i)==0) ...
0
votes
0answers
42 views

C++ ORM - but the other way

After days of searching and studying and making my brain wired I will try to put my thoughts and "questions" here. I think that there are millions of reasons for using ORM tools like ODB (together ...
3
votes
1answer
156 views

raw, weak_ptr, unique_ptr, shared_ptr etc… how to choose them wisely

There is a lot of pointers in C++ but to be honest in 5 years or so in c++ programmation (specifically with the Qt Framework) I only use the old raw pointer : SomeKindOfObject *someKindOfObject = ...
0
votes
1answer
54 views

Adding permanent objects to a vector

I'm relatively new to C++ (coming from Java) and I've got a little problem regarding lifetime of objects. My situation is like this: I'm having a class A in which I'm trying to add elements to an ...
-3
votes
0answers
52 views

Are gdb debugger and g++ compiler (by command line interface) used in industry while developing c++ application software in unix [on hold]

Is gdb debugger with command line interface used in industry while developing application software(c++) in unix? If not which IDE will industry usually use while developing application software(c++) ...
1
vote
1answer
83 views

Polymorphism Question

For the sake of the question I've taken this code from http://www.cplusplus.com/doc/tutorial/polymorphism/ class Polygon { protected: int width, height; public: void set_values (int a, ...
-5
votes
0answers
16 views

Unintended Iteration of a specific line inside a For Loop [migrated]

Do not worry about the purpose of the code. But I will post it below for reference: #include<iostream> #include<string> using namespace std; int main() { int numberOfStudents; ...
-3
votes
0answers
41 views

what knowlege is expected from 2years experienced c++ developer in linux domain? [on hold]

I was called for a job interview for the post of c++ application developer in unix domain. For 2 years I worked on various languages like c++, c, matlab. what do they want me to know in linux. 1.Is it ...
1
vote
3answers
94 views

Protect memory from a potentially seg faulting function call

How can one safely call a function that might segfault without corrupting the stack or the heap? These SO questions cover using signal handlers and setjmp.h to regain control. Coming back to life ...
1
vote
1answer
108 views

How to make sure that the destructor cannot throw an exception?

I know that we can specify the compiler that a function is not throwing an exception by using noexcept specifier but noxecept functions can still throw exceptions . So, how to prevent destructor from ...
1
vote
1answer
173 views

How to avoid violating one definition rule in this case?

We have an existing Mutex C++ class. It has a debug feature to track the owner thread id. So it has a member variable to store this, but because the original developer doesn't want to waste memory, ...
-3
votes
1answer
44 views

Ask advice on the improvement of my code [on hold]

My original part of the code for a matrix class is like this: Matrix::Matrix(const Matrix& mat) { int i; r = mat.r; c = mat.c; d = new double [r*c]; double* p = d; double* pm = ...
4
votes
2answers
297 views

Const means Thread-safe?

I was put onto this video: http://channel9.msdn.com/posts/C-and-Beyond-2012-Herb-Sutter-You-dont-know-blank-and-blank By http://codereview.stackexchange.com/users/39810/glampert Because I asked ...
0
votes
0answers
27 views

Can you write normal Windows applications with C++/CX? [migrated]

Or are you restricted to the "Metro style" applications and Windows Store apps? At first I thought C++/CX would be a good alternative to C++/CLI as it has some nifty C#-esque keywords ('sealed', ...
-1
votes
0answers
13 views

gdb will not run and hit breakpoints [migrated]

I am using unix with a project that deals with C++ source files. In the directoryuser/project/Build, I enter make to compile and link the source files and then go to user/run and enter run.sh ...
-1
votes
0answers
18 views

Is it possible to pass an exception to a handler and then rethrow the original exception? [migrated]

I am trying to write code which is passed a handler for when errors occur. class Handler { public: virtual void handle(std::exception const& e) = 0; }; class DoIt { Handler* handler; ...
2
votes
2answers
78 views

Free Standing Functions in Global Namespace

When writing non-member, free functions, can they be placed in the global namespace so long as the signature specifies a namespace-scoped object? For example, in the code below, is "Example 2" ...
-2
votes
0answers
25 views

How to handle the file more than 2G bytes when convert h264 raw stream to mp4 with MP4V2 lib on android platform? [closed]

I convert a h.264 raw stream file more than 2G bytes(>0x80000000) to mp4 file, with mp4v2 lib , but it can not be played. But if I read the raw file less than 2G (<0x80000000) then convert to mp4v2 ...
-4
votes
0answers
89 views

Do i have to learn mathematics deeply to be a software enigineer? [closed]

I do not know nothing about about Software Engineering but I want to be a software Engineer and I am interested in Computer and also I am very bad a Mathematics. Help me out. :)
-4
votes
0answers
101 views

Is there a type safe programming language for compiling kernel code? [closed]

As per the title, the linux kernel is like 90+% in C/++. The rest is practically all assembler. Is there any language that can be used to make type safe kernel objects? As in not C's level of unsafe. ...
-1
votes
0answers
95 views

Convert an 8 bit data to 3 bit data [migrated]

PROGRAMMING LANGUAGE: C I've a 8 bit data with only 3 bit used, for example: 0110 0001 Where 0 indicate unused bit that are always set to 0 and 1 indicate bits that change. I want to convert this ...
-1
votes
1answer
39 views

migrate a project developed under Borland C ++ Builder 5 to another IDE (Qt or VS) [closed]

I would like to migrate a project developed under Borland C ++ Builder 5 to another IDE (Qt or VS), also have your opinion on the feasibility and the different phases that you could advise me. I ...
-1
votes
0answers
49 views

what is the best book for data structure using c++ language? [closed]

i am studying data structure with Nell Dale book and i found it hard can you suggest any other book?
-3
votes
1answer
55 views

Request for some general advice from someone moving into software development [closed]

I've had a look around the StackExchange sites and this one seemed to be the most appropriate for my question. Apologies if I made the wrong choice, and I'm happy to hear alternative places to post. ...
3
votes
1answer
96 views

Convince Windows SmartScreen and web browser that my application is safe?

I am developing a Free and Open-Source software (C++). When I download my own application from a web link, Microsoft Smart Screen and Google Chrome are getting in the way since it comes from and ...
2
votes
2answers
91 views

Typedefs to convey relations between classes

I'm wondering if the following use of typedefs is any good practice, or if there are any downsides to it. Basically I have alot of "data"-structs, which are intended to be used in (globally unique) ...
0
votes
0answers
28 views

C++ metaprogramming - compile time search tree [migrated]

Imagine I have to statically initiailize a search tree each time mine program is executed. Tree t; t.add(1.0, 'Apple'); t.add(2.0, 'Pear'); t.add(5.0, 'Orange'); ... t.add(30.0, 'Cucumber'); .. // ...
3
votes
2answers
129 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, ...
1
vote
2answers
59 views

Logging function names on systems with few (memory and space) resources

Our logging module has a buffer that often gets full and we are searching for a solution to shorten our logs, without making any compormise in performance. The code is written in C++ and currently we ...
0
votes
5answers
487 views

Is a makefile really needed

I have been programming in c/c++ for a while now, and I have never once used a makefile. I know that it is supposed to be useful when you are dealing with a large project, but I have always been able ...
0
votes
0answers
43 views

Polymorphic template container: shared_ptr vs reference_wrapper

Assuming we have two classes: class A { ... } class B : public A { ... } Would it be better to write std::deque<shared_ptr<A> > container; or ...
0
votes
1answer
48 views

Perrin sequence help c++

Hey everyone I am trying to write a recursive function for a perrin sequence where it returns the nth term that a user enters which is: P(0) = 3, P(1) = 0, P(2) = 2, and P(n) = P(n − 2) + P(n − 3) ...
56
votes
11answers
7k views

Why is base-for-all-objects discouraged in C++

Stroustrup says "Don’t immediately invent a unique base for all of your classes (an Object class). Typically, you can do better without it for many/most classes." (The C++ Programming Language Fourth ...
3
votes
2answers
614 views

How do you usually compile C/C++ source code ? (Large code bases) [closed]

It's been quite some times since I began learning C and C++ but I've been very limited only to the Windows platform and the Visual Studio environment. Recently, I wanted to look into some open source ...
3
votes
1answer
128 views

How can I use the “Non-Member Functions Improve Encapsulation” pattern from C#?

In 2000, Scott Meyers argued that non-member functions improve encapsulation. In C++, a non-member function is a C-style global function: ...
0
votes
1answer
65 views

C++ Templates where the type is a shared_ptr

When creating template classes in C++, if the type upon which the template will be specialized is intended to be a shared_ptr type, is it better to make T a shared_ptr type or make T a non-pointer ...
0
votes
2answers
102 views

Organizing C++ Components [closed]

In my current company we've brought the discussion about how to organize most of our different C++ components considering the following requirements: There might be interdependencies between ...
2
votes
1answer
164 views

An embedded C developer wishing to interface some code with a web page

Okay, so as the title says, I'm an embedded C/C++ developer. Right now, I'm working on a project that involves a client/server C application. The server side of the application is running on ...
-1
votes
5answers
1k views

Why Java is a factor 2-3 slower than equivalent C++ program? [closed]

I know there is an opinion that programs written in Java and running under JVM as as fast as C++ programs, after introducing just-in-time (JIT). I see many cases when Java is terribly slow for simple ...
0
votes
1answer
99 views

Is it not direct usage of primitive pointer types form of Primitive Obsession?

Using primitive data types to represent domain ideas is code smell called Primitive Obsession. For example using string data type to represent human name - it is recomended to avoid this by defining ...
1
vote
1answer
51 views

Should factory make context or concrete strategies objects in strategy-factory pattern?

In a typical strategy pattern class Strategy { public: virtual int execute() const = 0; } class StrategyA : public Strategy { public: int execute() const override; } class StrategyB : ...
2
votes
1answer
167 views

Well defined mathematical operations for bearing (angle) class

I have written a class to represent bearings (angles with a nautical theme, and a specific normalisation range). In the program, it is necessary to perform some mathematical operations on them, so ...
0
votes
0answers
70 views

How to avoid default member construction? [migrated]

I`m implementing move constructor and operator= for my class and I wish to implement moving only once inside operator=(). But member object constructed constructed before constructor body executes and ...
-1
votes
0answers
19 views

Shortcomings in the program (Linked Lists: Deletion and Searching) [migrated]

The following pseudo-code deletes a node from the linked list. void list::erase()//Deletes a node { cout<< "Enter a position: "; cin>> pos; if(pos==1) { current=head; ...