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

learn more… | top users | synonyms

-2
votes
0answers
201 views

I'm really terrible programmer. please help [on hold]

I'm doing my 3rd year in BSc Software Engineering. I managed to pass all the exams but. I'm really a terrible programmer. I want to learn everything about programming concepts. but don't know where to ...
0
votes
0answers
48 views

Use of SAL annotations for C++ [on hold]

Code analysis tool for visual studio is able to detect some kinds of errors statically if you annotate functions with SAL We used it at first in windows driver when code was mostly C code, and where ...
-3
votes
0answers
52 views

Creating a simple Window program [on hold]

so I am new to programming I am using mainly the console do program.And since I am a beginner I was wondering how can I make a simple window program with Text?I am sorry for my newbie question but I ...
-5
votes
0answers
28 views

C++ template error [on hold]

I keep getting this error when I make my program. I have no idea why. Any help is appreciated! g++ -g -Wall main.cpp -o lab10 main.cpp: In function ‘int main()’: main.cpp:22:29: error: no matching ...
-5
votes
0answers
81 views

What are the basics of software engeneering [on hold]

I want to be a software engineer what is the process where to start I want everything to be online.
-2
votes
0answers
55 views

interoperability java and c++ [duplicate]

i want to write a program in two different languages java and c++ that needs a dynamic and interactive communication between its c++ component and java component.i know there is jni and jna for ...
-4
votes
0answers
81 views

Does C# meet my all of my needs? [closed]

TL;DR: Are there any serious issues with using C# over Java for mobile dev and would I be more likely to find jobs in game development with C++ or C#? -- At the moment I'm familiar with HTML, CSS, ...
-6
votes
0answers
34 views

Spoj Trie Problem [closed]

Recently I've tried to solve a problem of SPOj. After submitting the solution it is giving me WA. :( I've tried with some cases and every input is giving me correct answer. But as the online judge ...
1
vote
1answer
118 views

how can i make a program written in c++ with qt to text and graphic mode?

I have seen in many programs, almost only on linux, that when you run the program with a graphical manager(Clicking the executable) the program runs in a graphical window and when you run it from the ...
-4
votes
0answers
39 views

How can I create a program which records how much internet data is used by each website visited? [closed]

I don't believe this is even possible but it's worth asking, I would like to create a batch file that when run, it will record all IP addresses or URL's visited during an internet session. It won't ...
-4
votes
0answers
31 views

measure cache memory allocation [on hold]

I'm facing an homework where I should "fill the register inside the CPU using C++". While I understand that a single register should be once or twice the word size of the system and the L1 cache ...
-8
votes
0answers
47 views

Using variable in string text. Hexadecimal system [closed]

I have constans variable like : A=10, B=11, C=12, D=13, E=14, F=15. I would like to add written two number in hexadecimal system. When I get last letter from string (ex. "43251A") I want this "A" was ...
2
votes
2answers
68 views

Optional Member Data

I am creating a strong binding of an XML specification and I am essentially trying to "flatten" the specification as much as possible, so that it won't feel like you are manipulating an XML tree. ...
-2
votes
0answers
5 views

Really confused about map::erase() [migrated]

//test #include <map> #include <iostream> using namespace std; int main() { map<int, string> Inventory; Inventory[1] = "Sword"; Inventory[2] = "Armor"; ...
16
votes
5answers
3k views

Do enums create brittle interfaces?

Consider the example below. Any change to the ColorChoice enum affects all IWindowColor subclasses. Do enums tend to cause brittle interfaces? Is there something better than an enum to allow for ...
0
votes
0answers
102 views

Class Method with specialized Parameter [migrated]

Is is possible to create a template method with flexible parameter list, like this: class TestA { public: TestA(int i, int j) { ... } } class TestB { public: TestB(std::string a) { ... } ...
1
vote
1answer
94 views

component-based power system for a game [closed]

My issue is that I've been trying to implement a power/electrical system for a while now. I'm using Unreal Engine 4 with C++ but that's not really relevant. I'm trying to implement some sort of ...
1
vote
1answer
69 views

Experiences with C++ Async/actor model Library [closed]

I am fairly experienced with async and concurrent programming in c# using event, actor, and task based patterns, but now I have a task in c++ with which I have basic familiarity and it needs some ...
-1
votes
3answers
109 views

Java and C++ connection? [closed]

Quick question about them. Are they semantic kind of way related? I am learning C++ and I want to start java too. Can I get confused when learning the two languages?
3
votes
3answers
297 views

in C++, how to call an 'init' routine as a class is loaded?

I have a program that loads a bunch of "addons" (different meters that measure and display system values). The "addons" have "grown" over time and the code of what addons to "activate", and how many ...
0
votes
1answer
98 views

Best algorithm for “ACM ICPC Team”

I have this problem (complete description): There is a list of persons N and M topics. I have to find out the maximum number of topics a 2-person team can know. And also find out how many teams can ...
-2
votes
3answers
230 views

Programming in Linux (C++) [closed]

So I don't know If this is the right place to ask this. I am new to programming, I am not very in to it (I know classes,arrays,functions..etc(Basic Things)). I was programming with Visual Studio 2013 ...
15
votes
4answers
2k views

Why aren't `void *`'s implicitly cast in C++?

In C, there is no need to cast a void * to any other pointer type, it is always safely promoted. However, in C++, this is not the case. E.g., int *a = malloc(sizeof(int)); works in C, but not in ...
-3
votes
1answer
117 views

Physics/Game Engine in C++ for mobile app [on hold]

First post so be gentle. I am a junior seeking a Comp Sci major and was looking into making a mobile game. I wanted to use this for my thesis project next year, and possibly a way to pay back college ...
1
vote
1answer
87 views

Avoiding std::forward and Rvalue References

I recently read the Google C++ Style Guide and especially one part catched my eye. The part about Rvalue References discourages from using std::forward in general and using rvalue references in other ...
3
votes
0answers
249 views

Way to toggle debugging code on and off [migrated]

I was programming a manchester decoding algorithm for arduino, and I often had to print debug stuff when trying to get things working, but printing to serial and string constants add a lot of ...
-2
votes
1answer
94 views

Is visual c++ cross plat [closed]

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
1answer
115 views

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

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 ...
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 ...
3
votes
1answer
230 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
72 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 ...
1
vote
1answer
112 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; ...
1
vote
3answers
109 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
127 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
189 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, ...
4
votes
2answers
328 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 ...
2
votes
2answers
86 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" ...
4
votes
1answer
106 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
98 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) ...
3
votes
2answers
181 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
65 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
513 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
65 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
50 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) ...
57
votes
11answers
8k 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
663 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
138 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
83 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
105 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 ...