I am trying to compile my first c++ file on windows with the g++ compiler...
My cpp file is the following -
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
I type in this on command prompt to get to the directory
cd C:\Users\Mark
Then to compile my program I do
g++ hello.cpp
It cr...
for(ItemTemplateListIterator iter = item_template_list.begin(); iter != item_template_list.end(); ++iter) {
int id = iter->first;
string description = iter->second->description;
some_file_stream << id << endl;
some_file_stream << description << endl;
}
Where item_template_list is a map of <int, MyClass*>, ItemTemplateL...
Hi there, I'm reading data from a file into a vector of strings called data. And to this data vector I push_back a new string through my main called output_string. Output_string is just a combination of the arguments passed in through command line. After doing all that I write back to my file(update the file with the new string). However...
Hello,
This may have been asked previously, but I search the stack and couldn't find any which really hit upon this.
I just finished work on a C++-program where I've implemented my own exceptions (although derived from std::exception). The practice I've applied when one exception causes a chain reaction, propagating the error upwards a...
What is the C++ (and or visual-C++) analog of C# byte[]?
...
Our analytic server is written in c++. It basically queries underlying storage engine and returns a fairly big structured data via thrift. A typical requests will take about 0.05 to 0.6 seconds to finish depends on the request size.
I noticed that there are a few options in terms of which Thrift server we can use in the c++ code, speci...
Hi,
I am attempting to use OpenMP in my project that contains N agents in a simulation. Every agent has a position vector. Inside my program, I do something like the following:
for(int i=0;i<agents.size();i++){
for(int j=0;j<agents.size();j++){
if(i==j) continue;
if(distance_between(i,j)<10){
//do a lot of calculations for ...
I find myself stumnped by what should be a simple problem. How do you make a class (created in a seperate file) have global scope when using forms in Microsoft C++. I can declare, initalize, and use it in a textbox leave or keypress function but when I move to a button it is out of scope (the button and textbox have global scope, but I...
Suppose in a method MA() of class A, a method MB() of class B is being called after creation of an object. Is there a way to know in MB() the name of the class and the method from which it is being called in C++ ??
...
I know what the basic idea there is, but I was thinking, and I realized, that it would therefore take MORE characters for a switch statement than for a bunch of if statements,
since an if statement has 7 characters (not including the variable name, nor what it is being compared to, nor the code), while the switch statement has 9 charact...
Although most of the time it's C:\WINDOWS\system32, but sometimes it can be in D partition or alike, how to get it programatically?
...
When generating VS2010 targets with CMake, I would like the /LTCG flag turned on (only for release + releasewithdebinfo if possible, but its okay if its on for debug builds). How do I modify the linker flags? add_definitions() doesn't work because that only modifies compiler flags. And yes, I have wrapped it in if(MSVC).
How do I modify...
I have a very simple interface which needs to communicate between processes. It's currently implemented in a very simple manner (all single proc):
bool GetFoo(struct Foo *outFoo);
bool GetBar(struct Bar *getBar);
Such as:
Foo foo;
if (!GetFoo(&foo))
{
ReportError();
}
GetFoo fills out the "Foo" data structure with pure data (t...
Can you create a PNG, GIF, etc with C++ on windows?
If it's possible, how? For an example how can you make a png image just one solid color.
Just a "hello world" example would be great...
...
I've heard that recursive mutexs are evil but I can't think of the best way to make this class work without one.
class Object {
public:
bool check_stuff() {
lock l(m);
return /* some calculation */;
}
void do_something() {
lock l(m);
if (check_stuff()) {
/* ... */
}
...
Possible Duplicate:
Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7
I was asked a simple question (purely in interest), in it there's a function which supplies a random number between 1 and 6, now with based off that function you need to...
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)
If hWnd is NULL, PeekMessage retrieves
messages for any window that belongs
to the current thread, and any
messages on the current thread's
message queue whose hwnd value is NULL
(see the MSG structure). Therefore if
hWnd is NULL, both window messages and
thread messages are pro...
Can I use the reverse geocoding server side, e.g. with a C# or C++?
EDIT: I get some list of longititudes and latitudes from GPS Mouse, And I need to find all the corresponds addresses and save it to database. I am not interested to show on a map.
...
Hey all. I've downloaded and moved the Xerces (v3.1.1) source here: /usr/include/xerces and I can see the source in the project explorer like this:
MyCppProject
Binaries
Includes
[...] // some other directories
xerces
dom
[...] // some other directories
And, here's my simple C++ code:
#include <xercesc/util/PlatformUtils...
Following fails to catch a exception
int *i; //intentionally uninitialized
try {
*i = 6;
}
catch (const runtime_error e) {
cout << "caught!" << endl;
}
is it actually catching a runtime error or an exception?
...