I am using boost shared pointers in my program, and I have a class that takes as a parameters a reference to another object. The problem I am running into is the make_shared function requires all parameters to be a const reference, and I get compile errors if my class's constructor doesn't allow const reference parameters to be passed i...
I was wondering if there are any opensource libraries that are geared towards transportation ben/cost analysis.
I currently use microBENCOST and would like to build my own solution. I'm most comfortable with C/c++ and Python.
cheers
...
I'm trying to rebuild someone's old C++ project using Dev-C++ (version 4.9.9.2) and the standard compiler that it comes with (I think g++ using MinGW) under Windows XP Pro SP3 32-bit. In one of the files strsafe.h is included and when I try to compile, I get this error:
expected primary-expression before ',' token
The lines of code th...
I have a previous question that was answered in which I describe difficulties catching an exception when I try to access an object that has been deallocated by a third-party function. The function sometimes does and sometimes doesn't deallocate the object.
In order to avoid having to use a try/catch block to catch the SEH Exception a...
I have the following C++ code:
#include <math.h>
#include <cmath.h> // per http://www.cplusplus.com/reference/clibrary/cmath/abs/
// snip ...
if ( (loan_balance < 0) && (abs(loan_balance) > loan_payment) ) {
...
}
and make blows up on:
error: call of overloaded 'abs(double)' is ambiguous
also of interest:
/usr/include/s...
Hello,
I have a problem linking an application for an embedded target. I'm developing on a windows box using Min-GW for an ARM9 target that runs under Linux.
Actually I'm switching from static linking to dynamic linking with .so-libraries to save memory space.
I get the error message
libT3Printer.so: undefined reference to `__ASSERT'
...
I have a class like this:
class A
{
private:
B* ptr;
}
But B ptr is shared among different A objects.
How can I use auto_ptr so that when A gets destructed B stays on so that other A objects that point to the same ptr can continue without issues.
Does this look ok:
class A
{
public:
auto_ptr< B > m_Ptr;
private:
B* ptr;
}...
Can someone please show a simple, but complete example of how one could use Boost exception library to transfer exceptions between thread by modifying the code below?
What I'm implementing is a simple multi-threaded Delegate pattern.
class DelegeeThread
{
public:
void operator()()
{
while(true)
{
// Do some work
...
Is there any difference between type casting & type conversion in c++.
...
I have a following code in a most inner loop of my program
struct V {
float val [200]; // 0 <= val[i] <= 1
};
V a[600];
V b[250];
V c[250];
V d[350];
V e[350];
// ... init values in a,b,c,d,e ...
int findmax(int ai, int bi, int ci, int di, int ei) {
float best_val = 0.0;
int best_ii = -1;
for (int ii = 0; ii < 200; ii++) {
...
My question can be boiled down to, where does the string returned from stringstream.str().c_str() live in memory, and why can't it be assigned to a const char*?
This code example will explain it better than I can
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
stringstream ss("this is a ...
I am new to C++ and STL. I am stuck with the following simple example of a hash set storing custom data structures:
#include <iostream>
#include <ext/hash_set>
using namespace std;
using namespace __gnu_cxx;
struct trip {
int trip_id;
int delta_n;
int delta_secs;
trip(int trip_id, int delta_n, int delta_secs){
th...
Just a conceptual question that I've been running into. In my current project it feels like I am over-using the boost smart_ptr and ptr_container libraries. I was creating boost::ptr_vectors
in many different objects and calling the transfer() method to move certain pointers from one boost::ptr_vector to another.
It is my understandin...
I'd like to override the behavior of an std function, say std::time. Is it possible to call std::time and have it routed through my custom function?
...
In Perl, there is a UNIVERSAL::can method you can call on any class or object to determine if its able to do something:
sub FooBar::foo {}
print "Yup!\n" if FooBar->can('foo'); #prints "Yup!"
Say I have a base class pointer in C++ that can be any of a number of different derived classes, is there an easy way to accomplish something si...
Based on feedback I got from this question, I'm interested in using Lazy C++ on my OSX laptop. The Lazy C++ webpage has binaries for Linux and Windows available, but nothing for OSX. There's also a link to download for the Lazy C++ source, but it requires a lzz binary as part of the build process. This creates a situation where I need an...
I'm developing an application which needs to count user keystrokes. It works fine however user can trick the app with SendInput() WINAPI function. Is it any way to differentiate between keystrokes made by real user and those sent via SendInput?
...
how does fprintf works??
if i write fprintf(outfile, "test %d %d 255/r", 255, 255);
what does it mean??
i know outfile, is the name my of output file.
what would the other values mean?
...
I'm seeking C++ help in writing HTML code to a new tab in Firefox within an extension.
Our C++ code has been partially wrapped by an XPCOM wrapper and embedded within a Firefox extension thanks to the work of a consultant we have lost contact with, and still partially implemented by calling out to a standalone executable.
To get our ou...
If the constructor for Door looks like this:
Door::Door(Doorknob doorknob) : m_doorknob(doorknob) { }
Then you would instantiate a Door like this:
Doorknob doorknob;
Door door(doorknob); // Does an object copy of doorknob occur here?
It seems like if you store Doorknob as a pointer, you can explicitly avoid the copy:
Door::Door(D...