I've been testing part of my code responsible for filling multimap object, when a weird error started to pop up:
int SetPortName(string ID, string Name)
cout << "ID: " << ID << " Name: " << Name;
...
}
works fine under non-root user in FreeBSD 5.4, but crashes with "Bus error" while ran under root.
...
There is a problem compiling Ogre with MFC in debug mode, you get an error because of the MFC macro:
#ifdef _DEBUG
#define new DEBUG_NEW
Which basically clobbers Ogre's debug new -
#define OGRE_NEW new (__FILE__, __LINE__, __FUNCTION__)
I'm trying to get MFC+Ogre to run merrily together in DEBUG mode, and I got it to compile with...
I have seen lots of kinds of interface to multithreading and locks.
These make me feel frustrating,
Some of them include 2 different classes like the sample below, while
others have only one class and the acquire() can implement the wait function.
My questions are:
Why we design locks like this in object oriented programming?
How t...
I get the following error in Visual Studio 2008: error C2248: 'Town::Town' : cannot access private member declared in class 'Town'. It looks like the constructor is unable to access the members of its own class. Any idea what's going on?
Here's the code:
I have this:
template<class T> class Tree{...}
And this class:
class Town{
...
Hi all, I was recently trying to gauge my operator overloading/template abilities and as a small test, created the Container class below. While this code compiles fine and works correctly under MSVC 2008 (displays 11), both MinGW/GCC and Comeau choke on the operator+ overload. As I trust them more than MSVC, I'm trying to figure out what...
Hi!
I'm wondering how do you do stuff like gettling file information, searching through directories/subdirectories in c++? Is there a particular library that I should be looking at?
I'm seeing stuff like this in some examples:
#include <sys/types.h>
#include <sys/stat.h>
Not sure where they came from.. Thanks!
EDIT: I'm programming...
Hi all,
I had a very weird problem with precompile header. The linker generates LNK2019: unresolved external symbol error when I implement method in .cpp file. However, the program could be compiled if I implement method in .h file. I happened to find out a solution but I have no idea about the root cause of this error.
My project str...
I have a
while(cin >> string)
loop in which I want the user to input a string. However, I do not know how to end the input. I know on *nix machines for bash shell, I can use ctrl-D. But this does not seem to work on cmd.exe for Windows...
Any tips?
[Edit] This is on C++
...
In C++ I would like to define some strings that will be used within a class but the values will be common over all instances. In C I would have used #defines. Here is an attempt at it:
#include <string>
class AskBase {
public:
AskBase(){}
private:
static std::string const c_REQ_ROOT = "^Z";
static std::string const c_REQ_PRE...
I'm writing C++ console programs. After compilation, when I run the program from my file browser, cmd.exe automatically closes such that I can't see my programs output.
The only way to work around this I've found is to run the program from inside cmd.exe
Is there anyway to keep cmd.exe open after a program finishes running?
Is there a...
Considering these two structs:
struct point {
int x,y;
};
struct pinfo {
struct point p;
unsigned long flags;
};
And a function, that changes a point:
void p_map(struct point &p);
Is it possible to use boost (e.g. boost::bind or boost::lambda) to create a function equivalent with:
void pi_map(struct pinfo &pi) { p_map...
I am trying to start unit testing. I am looking at a few C++ frameworks and want to try Boost.Test. The documentation seems very thorough, and it's a bit overwhelming, especially someone new to unit testing. So here's a situation that I want:
Let's say I have 2 classes, Foo and Bar. I want to write a suite of tests for Foo and a suite o...
Currently I am working with Java and its object oriented-design aspects (I also work with PHP/MySQL a lot). I don't implement it on the web; I just use it for designing programs for general purposes. However, now I need to learn C right now, and I have an interest in C++. I got The C Programming Language, which some people say is the bes...
Do you know of any package for distributing calculations on several computers and/or several cores on each computer? The calculation code is in c++, the package needs to be able to cope with data >2GB and work on a windows x64 machine. Shareware would be nice, but isn't a requirement.
...
In C, C++ and C# when using a condition inside a function or loop statement it's possible to use a continue or return statement as early as possible and get rid of the else branch of an if-else statement. For example:
while( loopCondition ) {
if( innerCondition ) {
//do some stuff
} else {
//do other stuff
}
...
Hi,
I have two C++ projects in a solution both of which need to share two common classes. What I want to avoid is having two copies of the source files but I am relucant to just include the source in one project and reference it in the other.
How is this sort of situation normally handled?
...
Is there any JavaScript library that can be used for calculations involving 700+ Digits?
Also, how about the same thing in C++?
...
Hi all.
I have a Shared Library wise.so. How I can use it in my programm? Do I need to include headers of that library?
I work with Eclipce under Linux. I have set a path to the library using -L and -l. But my function is not visible in the program.
Could you explain me how does Shared Library work?
Regards.
EDIT:
I get the follow...
I am trying to force gnu - cpp to keep special comments like /*+ ... / because I need them for optimiser hints. It worked well with cpp of xlc (AIX) but now I get an addtional space between slash and plus (/) ?
e.g.:
$ cat cpp-test.sql
#define _STAR *
#define OPT_HINT(x) /_STAR+ x _STAR/
select OPT_HINT(INDEX(TABLE table_pk)) * from t...
So in Code::Blocks in Ubuntu (latest).
I have a project in which I load a file and read a number from it.
#include <fstream>
using namespace std;
int main(){
ifstream in("data/file.t");
int n;in>>n;
}
now with a cout<<n it shows -1203926 (and other random numbers) though the number in the file is 0.
data is where the binary ...