C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.
2
votes
0answers
22 views
I've written an aimbot for an open source FPS game. Any suggestions?
The game is Assault Cube. Here is the source code:
/*
Control + 0 = enable aimbot
*/
#include "stdafx.h"
#include <math.h>
const float pi = 3.14159265358979f;
/*
* I am using int* as ...
0
votes
0answers
11 views
UVa 102 - Ecology Bin Packing Wrong Answer
So I've tested it against a few samples I have in mind, including the included sample I/Os.
Originally,
cost = Bottles moved away from Bin A, Bin B, and Bin C
Since each of them have only one ...
1
vote
1answer
44 views
How to make faster this algorithm? C++
I have a problem with my algorith and I need it to be much more faster, what can I do? What the algorithm does is take a matrix of NxK and search for the minimunDistance that is the least number of 1 ...
4
votes
2answers
59 views
Doubly Linked List Implementation C++, copy constructor and assignment operator
I have implemented a Doubly Linked List in C++. I have tested it and everything works as expected, but I am not sure if my copy constructor and assignment operator perform a Deep Copy. Can someone ...
2
votes
0answers
15 views
Reviewing a generic pipe and filters
I made a template pipe and filters to replace an old pipe and filters implementation that used inheritance and had a very heavy base class.
#include <iostream>
#include <boost/bind.hpp>
...
0
votes
0answers
14 views
reading input from keyboard
I am required to read from an keyboard(stdin), the following text. Pl note that it will be entered by user from keyboard in this format only.
#the total size of physical memory (units are B, KB, MB, ...
6
votes
1answer
80 views
i want to improve my program — what questions could/should i ask myself during the re-write?
tl;dr - i want to adopt good coding habits now. the below code was written under tight constraints. we don't do assignment post mortems in class to discuss "real world" best practices -- we just get ...
2
votes
1answer
38 views
Unable to understand seniors review comment.
I wrote the following code to read a config file line by line and split each line into 2 parts and store them separately. The split is done on the basis of a delimeter '=' :
std::ifstream ...
3
votes
2answers
42 views
How to avoid goto without replicating code in my meshing algorithm?
To generate faces of a Minecraft-like world from a three dimensional array, I developed the following meshing algorithm. The faces are given vertices and indices. A vertex consists of a position in ...
1
vote
0answers
11 views
Producer consumer frameskip?
I have a producer consumer that simulates the interaction of threads controlling a hardware device.
I have 1 thread controlling the device, 1 thread reading, and 1 thread outputting. The read is ...
3
votes
1answer
84 views
efficient smart pointer implementation in C++
So the idea behind this is mainly educational but I might even consider using it in reality if turns out to be good. Here's my first try at implementing smart_pointers
template<typename T>
...
3
votes
1answer
41 views
Writing/reading data structure to a file using C++
I wrote some piece of code which reads and write multiple data structures on a file
using C++. I would be grateful to get your feedback on what you think about the code (it works at least when I ...
1
vote
2answers
43 views
Does my classes contain right destructors
Every Account has its owner who is Person The bank has list of owners. I am not sure if my destructors are right and delete bank will delete all elements of list<Account*>* v nad the list ...
6
votes
1answer
80 views
How can I make this program a bit more efficient?
So I'm trying to solve a SPOJ problem, which code is SAMER08A and this is the link: http://www.spoj.com/problems/SAMER08A/
The problem, is that when I ran my code in my IDE, the code works perfect ...
3
votes
0answers
27 views
A c++ PEG parser generator
Last Weekend I wrote a c++ PEG packrat parser generator and would love to get some feedback on the code and/or syntax. I currently use the << operator for defining grammar expressions and ...
4
votes
1answer
52 views
C++: Generating similar methods with macros
I am currently working on a project that involves Lua. For convenience, I created a wrapper class for the Lua state structure. However, I also added some methods for getting globals and table fields. ...
5
votes
1answer
72 views
Simple “nullable” template class. Are there weaknesses in the implementation?
The goal is to have fields in a class which are optional and can be determined if they are set in order to be able to leave them out of serialization.
template<typename T>
class Nullable
{
...
1
vote
0answers
46 views
Random Generation From Sequences
With the inclusion of <random> into C++11, we can finally chuck out std::rand and start using generator with much better properties. Still, it's easy to get things wrong (uniform sampling where ...
3
votes
4answers
127 views
C++ vectors sort ascending/descending
How can I eliminate repetition from this code?
std::vector<std::wstring> vec;
bool descending;
if (descending)
{
std::sort(vec.begin(),
vec.end(),
...
3
votes
1answer
95 views
Fun with probability theory. Suggestions?
I want to play around with the Powerball lotto drawing history. What other probability theories could I try or what other probability class libraries exist. The code parses the file very quickly but ...
2
votes
1answer
69 views
How to design interface of deep-copy behaving pointer containers?
I want to make a container which manages big objects. which performs deep copies on copy construction and copy assignment. I also like the interface of the std containers, so I wanted to implement it ...
3
votes
1answer
38 views
C++ Url Decode Function Optimization
I have the following mock up that I need some feedback on how i might improve the url_decode function to make it faster and use less memory. There are a couple of requirements. I have to use the ...
5
votes
2answers
127 views
maximum equal in C++
When I need to get maximum value of A, B, and C, then I would write like:
val = A;
val = max(val, B);
val = max(val, C);
But, in this case, I need to write two "val" in the one line. And, it is ...
2
votes
1answer
60 views
skipping comment line from keyboard (stdin)
I have to write a code in c++ where the requirement is to skip a line beginning from '#' sign. So basically we need to treat it as a comment line. The input is given by the user from the keyboard. I ...
-1
votes
0answers
26 views
Trying to make siri applicaton in xcode using OpenEars [closed]
There I have made an application like sir where it asks you what it would like to search for then searches for it but i want to add....
when the person says hello
then program responds how are you
...
2
votes
0answers
93 views
Immutable C++ stack - thoughts && performance
What are your thoughts on the fallowing immutable stack implementation ? It is implemented having as a basis a C# immutable stack (where garbage collector assistance does not impose using a reference ...
1
vote
1answer
32 views
OpenGL abstraction layer
I tried to create a small OpenGL abstraction layer. I am an unexperienced programmer and I am relatively new to c++.
I tried to favor composition over inheritance but somehow it added extra ...
1
vote
1answer
36 views
Creating custom random access iterator in C++ 2011
I would like an opinion on my code. I need a random access iterator for my custom container.
If I read the C++ 2011 standard, specially chapter 24, I understood that an implementation
could be the ...
-1
votes
0answers
32 views
Operator Overloading [closed]
I'm trying to write a code that returns 1s and 0s instead of true or false.
But this doesn't seem to be right.
int Short_Vector::operator==(const Short_Vector& obj){
if(a == obj.a && ...
2
votes
1answer
88 views
Greatest prime number smaller than N where N can be as large as 10^18?
This is code for finding largest prime number smaller than N where N can be as large as 10^18.
But it takes 1 minute for 10^18 . I need to pass it in 2-3 sec.
What changes should I make to pass it.
...
0
votes
0answers
38 views
HashSet add and search functions
This is my first time implementing a hash set and I need your help. I know I didn't implemenet the operator= and the copy constructor(that's because I don't know how to), and the remove function. I ...
4
votes
2answers
167 views
HashTable - separate chaining collision in C++
guys! This is my first time here, and the first time I'm trying to implement a HashTable. In fact, I want a HashSet with Persons that have a name and a phoneNumber, both string. I understood the ...
2
votes
1answer
70 views
Can I make a regex array to iterate through in C++?
I have to check a string to various regular expressions in C++. Up to now, I've done this using something similar to this:
regex regex_a (".."); string rewrite_a = "($1/$2)";
regex regex_b (".."); ...
-1
votes
0answers
26 views
C++: Vector implementation copy constructor error [closed]
I'm trying to implement a version of vector (for learning purposes). My code fails to create second vector with copy constructor raising SIGABRT in insert() function. Still can't find my mistake. Any ...
2
votes
0answers
123 views
Best practice and/or cleaning binary/decimal/octal/hex converter (now for floating-point values)
This new code comes from my original converter (without floating-point support): Cleaner and/or more practical code for decimal/binary/hex converter
I've had some trouble implementing floating-point ...
3
votes
1answer
47 views
Selecting element from a collection based on bitwise-and result
I need to improve this section of code:
uint32_t to_handle = 0;
uint32_t test_const1 = Constraint3::VAL1 + Constraint3::VAL2;
uint32_t test_const2 = Constraint1::VAL2 + ...
1
vote
0answers
34 views
Design issue with decoder class
I'm designing a C++ Decoder class for decoding a format, and would like some feedback on my design choice: I want the user to be able to provide input to the decoder by either supplying an array, a ...
1
vote
1answer
87 views
How do I design this code better?
ALL,
I am developing a program that uses GUI and SQLITE.
For the GUI I use wxWidgets and use SQLITE API directly.
Right now I have a main frame class CFrame and database class CDb. The CDb class ...
1
vote
1answer
59 views
std::string/std::wstring template wrapper for Win32 API
I have not completed this but want to make my own template library for wrapping the Win32 API to make it compatible with std::string/std::wstring... Here's a sample of what I've worked with so far.
...
5
votes
1answer
245 views
Code Review for Hangman in C++
I have the following C++ program:
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
void printVector (std::vector<int>& vec)
{
for (int ...
1
vote
1answer
59 views
Simplify bit flags checking code
Please help make this code more cleaner. It's a part of window procedure that notifies my renderer before client area of window resized.
I need to check two combinations of bit blags: some of them ...
-1
votes
0answers
33 views
C++/Math - Camera class has max height climb issue [closed]
For some reason, there seems to be a limit to the height my camera can climb. It seems that no matter the pitch, it doesn't go directly the direction the camera is facing. If I am at say 75 degrees it ...
2
votes
3answers
143 views
Cleaner and/or more practical code for decimal/binary/hex converter
I've finally finished my converter and have determined that it works, but I'm trying to make it cleaner and/or more practical (primarily with the switch statements). I could probably put more things ...
-1
votes
0answers
31 views
Array sorting code and file IO [closed]
I would appreciate if someone could help me finalise a code.
I need to read in people's info (such as ID, age, etc.) from a text file into different arrays. Records are like this
2012317109 Jamie ...
0
votes
4answers
90 views
c++ concurrent queue with pthread implementation
I'm writing a multi-threaded queue implemented with pthread. Since I came up with the code based on several tutorials from Internet, I would like to make sure there is no logic error in my code:
...
4
votes
3answers
117 views
All integer sequences given amount of integers and length of sequence
Given two integers, X and Y, you must create all possible integer sequences of length Y using the numbers from 1 to X.
For certain reasons, the function must return a deque<deque<int> > ...
3
votes
1answer
55 views
Console menu, input stream - keeping clean code
I've written simple numeric menu which displays in the console. When user clicks '1', something happens, then when he clicks enter, I clear the whole output except for the menu itself. When the user ...
4
votes
4answers
148 views
General advice on a practice linked_list for C++ classes/templates
Introduction
I'm learning C++ (Coming from Haskell, C, and Assembly - and other languages sparsely) and this was my practice with classes and templates. It's a linked list that you can call in this ...
4
votes
1answer
70 views
Thread-Safe Game Engine: Multi-Threading Best Practices?
I'm writing a multithreaded game engine, and I'm wondering about best practices around waiting for threads. It occurs to me that there could be much better options out there than what I've ...
0
votes
0answers
31 views
Understanding macro cpp coding practice [closed]
I am trying to understand the following code: http://pastebin.com/zTHUrmyx I have compiled the code and am trying to use gdb to step through the code.
Specifically, I'm trying to understand EXECUTE ...




