Questions tagged [c++]

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.

Filter by
Sorted by
Tagged with
5
votes
3answers
7k views

Max repeated word in a string

I was trying to do a very common interview problem "Finding the max repeated word in a string " and could not find much resources in net for c/c++ implementation. So I coded it myself here. I have ...
4
votes
1answer
419 views

Anything I'm missing on this delegate implementation?

Just as the question states and to be sure, am I missing anything on this? Something important/obvious that I overlooked? As is, I can save any functor, function pointer and member function pointer ...
6
votes
2answers
468 views

Optimising a custom tree data structure

I have the following 'custom' tree data structure. This concept was to be thought of as, if given ("abb", 20) and ("abc", 30), then Tree['a']['b']['b'] == 20 <...
6
votes
2answers
2k views

Optimizing WordWrap Algorithm

I have a word-wrap algorithm that basically generates lines of text that fit the width of the text. Unfortunately, it gets slow when I add too much text. I was wondering if I oversaw any major ...
9
votes
2answers
5k views

OpenGL forward-compatible context creation on Windows

Is this the proper method for creating an OpenGL 3.3+ forward-compatible context? ...
5
votes
3answers
942 views

Quicksort application

What do you think about this code? ...
4
votes
3answers
12k views

Reverse a word using string manipulation

...
8
votes
1answer
209 views

Simplifying a Resizing Method

I'm making a simple container class for fun and education, but my rebuilding/resizing method seems rather inefficient. Is there an easier way to do this? ...
14
votes
2answers
15k views

C++ string_cast<> template function

In C++, to simplify string conversion between std::string and std::wstring, I created the following utility template functions: ...
6
votes
2answers
307 views

Counting the total number of characters in an std::set<std::string>

I have a std::set<std::string> and I need to know the total number of characters (sum of all strings length): ...
9
votes
6answers
5k views

Linked List program

This is a simple linked list program which creates a list by appending an object at the tail. It compiles and runs perfectly. Is the coding style, logic etc are fine? How can I improve this program? ...
14
votes
11answers
1k views

Design dilemma: extensibility vs simplicity

Here is my problem abstracted to Bird classes. I know that number of Birds will increase on the future and new behaviors might ...
11
votes
2answers
5k views

Improving HashMap in C++

I have created a HashMap<string,int> in C++. I would like help determining if it is good or bad. I have not handled the errors or successes with messages. I ...
14
votes
2answers
495 views

Retrieving list of flight numbers from flight path

The below is \$O(n^3)\$. I'm sure there is a way to improve this.. ...
13
votes
1answer
3k views

Path finding function

Could this be made more efficient, and/or simpler? It's a path-finding function. It seems to work, but do you see any potential cases where it could fail? ...
9
votes
1answer
265 views

Interpolating given value and legacy value from serialization buffer

Here's a function that interpolates between a given value and a value fetched out of a legacy serialization buffer: ...
16
votes
2answers
2k views

Eratosthenes sieve and MPI

I wrote this sieve of Eratosthenes with MPI, but I'm not sure if it's good enough. Should I use MPI_Scatter and MPI_Gather ...
12
votes
6answers
1k views

Class for holding person's information

I have written another program in C++. Excluding the point that the class definition should be in a separate header file, is there anything that needs to be improved? ...
13
votes
8answers
6k views

"Hello, world!" program using a class for printing

Please take a look at my program and let me know how I can improve it. ...
15
votes
2answers
635 views

Sudoku Grid special purpose Iterators

Please have a look at these iterators which I use for my Sudoku solver. They behave slightly different from STL iterators and don't implement all functionality that would be needed to use them in a ...
70
votes
8answers
12k views

Open, write and close a file

I have a small 10-liner function that writes some data to a file using an std::ofstream. I did not explicitly call .close() at ...
28
votes
6answers
55k views

Class for measuring distance as feet and inches

My homework question states: Develop a class to measure distance as feet (should be int), inches (should be float). ...
40
votes
9answers
109k views

Converting between std::wstring and std::string

While researching ways to convert back and forth between std::wstring and std::string, I found this conversation on the MSDN ...
23
votes
7answers
27k views

Function for removing forbidden characters

...
11
votes
5answers
728 views

Resolving a link - follow-up

Similar piece of code to that I recently posted as: Resolving a link I have another piece of code which cannot be as easily extracted out into a method: ...
38
votes
6answers
3k views

Resolving a link

How can I clean this up? ...
27
votes
6answers
2k views

Formatter class

In our production code, we cannot use Boost or C++0x. Formatting strings using sprintf or stringstream is annoying in this case,...
20
votes
4answers
3k views

Custom checksum algorithm

A while back, I reverse-engineered a checksum algorithm from an MMO used to check the validity of an item that's linked to chat (similar to WoW). The idea is that if the checksum is invalid then the ...

1
169 170 171 172
173