Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 5209

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. This tag should be used for any question which requires knowledge or expertise with the C++ programming language. This is a general tag which is used for any of the C++ language standards (C++98, C++11, C++17, etc.). The question should identify the compiler being used, the operating system, and which of the C++ standards is being targeted.

1 vote

Display students of specific age using struct

#include <cstring> You're not using any of the features in that header. Replace is with <string> and do use those. Also indent your code, it makes it more readable. struct student { std::string n …
Mat's user avatar
  • 3,025
32 votes
Accepted

Converting array of bytes to the hex string representation

Yes, but I doubt you'll see any practical difference with such short input. Two ideas: reduce the number of possible dynamic allocations, and do the conversion yourself with a small lookup table. Yo …
Mat's user avatar
  • 3,025
5 votes

Time calculator for a given speed and file size

I see very few things to change, your code is easy to read. You're not validating the input. What if someone enters something that's not a number? I'd suggest you create a function that takes the p …
Mat's user avatar
  • 3,025
3 votes

Abstract Interface for managing Init/Shutdown

I'm afraid to say I don't like this design. You seem to have put quite a lot of thought into it, but you really don't gain much with it. This is not an interface in the usual sense: it has state. In …
Mat's user avatar
  • 3,025
4 votes

Ticket sale income calculator

Don't use floating point numbers for representing money. Don't using namespace std, it's a bad habit that will bite you down the line. You've "double-spaced" pretty much all your code. That's too muc …
Mat's user avatar
  • 3,025
15 votes
Accepted

ROT47 Implementation

#include <cstring> #include <cstdio> You're not using either of those, so remove them, and include <string> instead to get std::string. std::string rot47(std::string s) { /* ... */ } Why copy the …
Mat's user avatar
  • 3,025
5 votes
Accepted

An attempt on unit testing in C++

I don't see anything wrong with your code as it is: formatting is consistent and tidy, functions do what they need to do and no more, no apparent bugs. One nit: your header file includes <iostream> b …
Mat's user avatar
  • 3,025
4 votes

Array to function to int arithmetic

Yes, that can be simplified at lot. *(&(coolPtr->map)) The * and & "cancel out" (assuming the expression is well-formed and both are otherwise legal), so you can drop them both, which leaves you wi …
Mat's user avatar
  • 3,025
5 votes

Dividing a range into N sub-ranges

#include <vector> // std::vector<T> #include <iterator> // std::distance(), std::next() Not a big fan of those comments, they tend to go stale pretty fast, e.g. here you're also "importing" std::c …
Mat's user avatar
  • 3,025
8 votes
Accepted

Recursive Memoized Fibonacci in C++

Not much to say: your code works as advertised, code is readable, formatting is consistent. Things that could be better though: don't use raw arrays with new unless you absolutely have to. Prefer std …
Mat's user avatar
  • 3,025
4 votes
Accepted

MyTimer based on QTimer

That's a lot of code indeed, and for all that code it is not very flexible: the "slot" name is fixed, you force multiple inheritance on your users, so they can have only one such type of timer - what …
Mat's user avatar
  • 3,025
3 votes
Accepted

Merge two sorted linked lists without recursion

You're duplicating the code to copy and merge nodes four times - that can't be good. You could move that into a separate function, but that might become messy because of all the state that has to be c …
Mat's user avatar
  • 3,025
2 votes

Video streaming client

Concurrency bugs In frameQueueGet: if(buffer->isFrameQueueEmpty()) { buffer->bufferWait(); } else { frame = buffer->getFrame(); // ... This only works if you have a single decoder thread. …
Mat's user avatar
  • 3,025
12 votes
Accepted

ASCII value converter

int main(int argc, char *argv[]){ //Declare Variables. string input; int size; Don't declare variables until you actually need them, and don't declare variables you don't need. In this c …
Mat's user avatar
  • 3,025
4 votes
Accepted

Simple implementation of a generic stack

In addition to MAG's answer, a couple of points. You're missing something related to memory management: what happens if someone copies one of your stacks as in: BBStack<int> s1(1); BBStack<int> s …
Mat's user avatar
  • 3,025

15 30 50 per page