I need to go through a set and remove elements that meet a predefined criteria.
This is the test code I wrote:
#include <set>
#include <algorithm>
void printElement(int value) {
std::cout << value << " ";
}
int main() {
int initNum[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
std::set<int> numbers(initNum, initNum + 10);
// ...
According to the documentation of iconv_open() over: http://www.gnu.org/software/libiconv/documentation/libiconv/iconv_open.3.html
"//TRANSLIT" means that when a character cannot be represented in the target character set, it can be approximated through one or several characters.
and:
"//IGNORE" means that characters that cannot be re...
Hi, I am exploring the option of querying a web-page, which has a CGI script running on its end, with a search string (say in the form of http://sw.mycompany.com/~tools/cgi-bin/script.cgi?param1=value1&param2=value2&param3=value3 ), and displaying the result on my app (after due processing of course). My app is written in MFC C++...
I've been searching in the web about this question and although there are many similar questions about read/write in C/C++, I haven't found about this specific task.
I want to be able to read from multiple files (256x256 files) only sizeof(double) bytes located in a certain position of each file. Right now my solution is, for each file:...
Why I can't compile this code?
#include <map>
using namespace std;
class MyTest {
template<typename T> void test() const;
};
template<typename T> void MyTest::test() const {
map<string, T*> m;
map<string, T*>::const_iterator i = m.begin();
}
My compiler says:
In member function ‘void MyTest::test() const’:
test.cpp:8: err...
What operators can not be overloaded in C++?
...
How do I define my own WM (like WM_CLOSE, etc) message that can be handled by the message pump in C++?
If that is even possible.
...
I have a set of classes that I've written in C++ for a code base that will run in Linux commandline. They primarily use the STL and no fancy features of the language. They've been tested, and work.
I need to write a GUI app for the .NET framework that does things using logic I've written in those classes, but run on Windows. A critic...
Game application is written in C++ and uses DirectX 8.
I am getting a maximum monitor resolution to calculate it's aspect ratio.
Then I use this value to fix game rendering (scale and set clipping to receive normal 4:3 image with black borders on wide screen monitors).
How can I check if monitor is using aspect ratio auto adjustment no...
The working draft explicitly calls out that defaulted-functions must be special member functions (eg copy-constructor, default-constructor, etc, (§8.4.2.1-1)). Which makes perfect sense.
However, I don't see any such restriction on deleted-functions(§8.4.3). Is that right?
Or in other words are these three examples valid c++0?
struc...
Hello all. I have a source file in my project, which has more than 65,536 code lines (112,444 to be exact). I'm using an "sqlite amalgamation", which comes in a single huge source file.
I'm using MSVC 2005. The problems arrives during debugging. Everything compiles and links ok. But then when I'm trying to step into a function with the ...
I am trying to improve SQLite error handling in an existing C++ program. I have a custom type SQLiteException, and I want to write a macro to print the line number, file name, and error messages from SQL.
I have the following functions defined:
LogMessage(LPCTSTR message); // Does the real work. Appends a timestamp to the message and...
I've got a simple class, and another class that has a property that points to the first class:
#include <iostream>
#include <vector>
using namespace std;
class first{
public:
int var1;
};
class second{
public:
first* classvar;
};
Then, i've got a void that's supposed to point "classvar" to the intended iteration of the clas...
The Given Problem:
Given a theater with n rows, m seats, and a list of seats that are reserved. Given these values, determine how many ways two friends can sit together in the same row.
So, if the theater was a size of 2x3 and the very first seat in the first row was reserved, there would be 3 different seatings that these two guys can...
Hey guys.
I'm trying to calculate a lookat matrix myself, instead of using gluLookAt().
My problem is that my matrix doesn't work. using the same parameters on gluLookAt does work however.
my way of creating a lookat matrix:
Vector3 Eye, At, Up; //these should be parameters =)
Vector3 zaxis = At - Eye; zaxis.Normalize();
Ve...
There are places where I check for valid pointers before I perform an operation with them; these checks can be nested pretty deeply sometimes.
For example, I have
if (a)
{
if (a->b())
{
if (a->b()->c())
{
a->b()->c()->DoSomething();
}
}
}
I really don't like the look of this. Is there a way to turn this into ...
Hello! I recently tried building my own shared and weak pointers. Code that compiles using Visual Studio doesn't compile in GCC (4.5.0) with the following error:
main.cpp: In function 'int main()':
main.cpp:18:27: error: no match for 'operator=' in 'wp1 = weak_ptr<int>(((const shared_ptr<int>&)((const shared_ptr<int>*)(& sp1))))'
weak_p...
Basically what the title says... I have created a class that models time slots in a variable-granularity daily schedule (where for example the first time slot is 30 minutes, but the second time slot can be 40 minutes); the first available slot starts at (a value comparable to) 1.
What I want to do now is to define somehow the maximum an...
Besides Qt, GTK, wxWidgets... What are the recommendations for a cross platform, open source GUI framework library that works with OpenGL?
...
Hi! Got the following warning output when using GCC 4.5.0 & MinGW.
Warning: .drectve `-aligncomm:___CTOR_LIST__,2 ' unrecognized
Warning: .drectve `-aligncomm:___DTOR_LIST__,2' unrecognized
What does it mean? I guess it's version-specific, because GCC 4.3.4 under cygwin didn't give that warning on the same project.
If anyone had the ...