Questions about C++, a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.
1
vote
2answers
55 views
What kind of base for Decorator: interface, abstract class, non-abstract
What should be at the top of inheritance tree of Decorator design pattern?
I mean the base for both components and decorators
non-abstract class: has data fields, implements methods
abstract class: ...
0
votes
0answers
79 views
Am I too old to start a Software Engineering Degree? [on hold]
Introduction
First post here. I'll start off with saying I am 23, turning 24 this November. Late last year I started learning the basics of programming and how to apply it. I currently work as a ...
3
votes
2answers
59 views
Design question concerning proper and practical encapsulation
I have been working on refactoring old code and found a lot of instances of the following type of situation: There is a master object which we call "Application" and there is only one of these. The ...
-3
votes
0answers
75 views
C++ on the offense [on hold]
I have just started learning C++ and I hope to use it alongside my interest in information security and ethical hacking. I know of a book called 'Violent Python', which demonstrates how Python can be ...
-2
votes
2answers
126 views
How to visualise this data model?
I have learnt different variants of list data model like Dlist, SList and recursivenodetype-list.
But I could not understand/visualise this datamodel as mentioned below in C++ syntax, with an ...
-4
votes
0answers
64 views
Why so much difference in compile time - python and c++ [on hold]
This is the question :
I wrote the following code which is in Python 3:
n,m = map(int,input().split(" "))
totTEAM = 0
problem = 0
stri = []
for i in range (0,n):
newstr = input()
...
-3
votes
0answers
76 views
Can I learn the basics of C++ through Parts I and II of Bjarne Stroustrup's book? [on hold]
I'm interested in learning the basics of C++ for the purposes of making me a better programmer. I do not code in C++, and have no immediate projects in mind that could make use of C++. But a lot of ...
-6
votes
0answers
47 views
Does microsoft prefers visual languages in his competition [on hold]
I’m confused about which language to prefer?
I know C, C++, VB.NET basics
I’m participating in a competition of Microsoft so should I prepare my vb.net or I should consist c/c++
Please Help me out ...
-1
votes
1answer
58 views
How to create a folder in a program's own directory, and create folders in the folders? [on hold]
I need my program to be able to create sixteen folders in its root directory where the .exe file is (Windows), and I need each folder to have preceding folders inside that contain more information, ...
0
votes
0answers
52 views
Use of SAL annotations for C++ [closed]
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
56 views
Creating a simple Window program [closed]
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
29 views
C++ template error [closed]
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 [closed]
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
83 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
40 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
132 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
33 views
measure cache memory allocation [closed]
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 ...
2
votes
2answers
70 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
97 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
70 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
303 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
100 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
234 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
121 views
Physics/Game Engine in C++ for mobile app [closed]
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
88 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
95 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
117 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
236 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
73 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
113 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
111 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
128 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
190 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
331 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
108 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
185 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
71 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
516 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
66 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
...