Hi,
I'm using VS2010 and I would like to call an exe file which I've created in another directory.
I've tried the following:
int main(){
system("C:\\Users\\Li\\Desktop\\Debug\\modelExample_4pcs.exe");
return 0;
};
but I get "The system could not find the file specified" error.
I've tried to run the exe file directly from...
I'm writing some code to handle video input from some cameras using DirectShow, so I have to implement ISampleGrabberCB.
My class that implements the interface compiles okay, but when I try to instantiate it the compiler raises "error C2259: 'SampleGrabberCB' : cannot instantiate abstract class".
Here is the interface I'm implementing:...
I have the following question and from a systems perspective want to know how to achieve this easily and efficiently.
Given a task 'abc' that has been built with debug information and a global variable "TRACE" that is normally set to 0, I would like to print out to file 'log' the address of each function that is called between the time ...
Possible Duplicate:
Best C++ Book for a Java Programmer with C and Python Experience
I've picked up a a few books, and browsed internet resources but they're not right for me as they spend most of their time showing you how to write a for loop or going over basic OOP concepts.
I'm looking for a transitionary guide like C++ fo...
Hi,
I'm running myself through a C++ text book that I have as a refresher to C++ programming. One of the practice problems (without going into too much detail) wants me to define a function that can be passed ifstream or cin (e.g. istream) as an argument. From there, I have to read through the stream. Trouble is, I can't figure out a wa...
I am trying to initialize an array of bools like so:
bool FcpNumberIsOk[MAX_FCPS]={true};
but when I debug it, I only see the first element of the array initialized, the others are false. How can that be so? I am using Qt on ubuntu 10 and the initialization is done on a local array inside a method.
Ok thanks for your answers.
...
I've read about POD objects in C++. I wanna have a POD struct to be written into a file. So it should have only public data with no ctors/dtors etc. But as far as i know it can have static function in it. So can I use "named constructor idiom" here? I need dynamic initialization, but I don't want to duplicate arguments checking at every ...
I am attempting to profile some c++ code, compiled with g++ including the option -pg, using gprof. However, in spite of the fact that the program takes 10-15 minutes to run on my computer (with the CPU maxed out), the % time, cumulative seconds and self seconds columns of the table produced by gprof are entirely 0.00s! The calls column c...
I would like to compare a character literal with the first element of string, to check for comments in a file. Why use a char? I want to make this into a function, which accepts a character var for the comment. I don't want to allow a string because I want to limit it to a single character in length.
With that in mind I assumed the e...
The standard does not allow code like this:
namespace Hello::World {
//Things that are in namespace Hello::World
}
and instead requires
namespace Hello { namespace World {
//Things that are in namespace Hello::World
}}
What is the rationale? Was this simply not thought of at the time, or is there a specific reason it is not inc...
Hi everyone,
I have a simulation written in C++ in which I need to maintain a variable number of agents, and I am having trouble deciding how to implement it well. Every agent looks something similar to:
class Agent{
public:
Vector2f pos;
float health;
float data[DATASIZE];
vector<Rule> rules;
}
I need to maintain a v...
Can anyone shed some light on this? From Bison's documentation, I didn't see anything related to this topic. Thanks very much in advance.
Mark
...
What does it mean if namespace in C++ is qualified with ::? For example ::testing::Test.
...
I have a set of cpp files that I want to compile directly into a binary and also to compile into a shared library.
I have
bin_PROGRAMS=mybin
lib_LTLIBRARIES=libmylib.la
COMMON_SOURCES=f1.cpp f2.cpp f3.cpp
mybin_SOURCES=main.cpp $(COMMON_SOURCES)
libmylib_la_SOURCES=$(COMMON_SOURCES)
When I run this the cpp files are compiled twice...
I'm trying to implement a program which runs a function limited by a fixed amount of time. I've managed to do it with pthreads but I would like to use Boost::thread. So far I've coded the following:
#include <boost/thread.hpp>
#include <unistd.h>
#include <signal.h>
#include <iostream>
using namespace std;
boost::thread mythread;
vo...
double numbers[ ] = { 1, 0.5 ,0.333333 ,0.25 ,0.2, 0.166667, 0.142857, 0.125,
0.111111, 0.1 } ;
std::vector<double> doublenumbers ( numbers , numbers + 10 ) ;
std::cout << std::accumulate ( doublenumbers.begin( ) , doublenumbers.end( ) , 0 ) ;
This produces 1, which is evidently wrong. Any explanations ?
Thanks ...
I have two threads in a producer-consumer pattern. Code works, but then the consumer thread will get starved, and then the producer thread will get starved.
When working, program outputs:
Send Data...semValue = 1
Recv Data...semValue = 0
Send Data...semValue = 1
Recv Data...semValue = 0
Send Data...semValue = 1
Recv Data...semValue = 0...
I have tried to implement a program using sockets in Ubuntu 10.04. Here is the code:
#include <iostream>
#include <sys/types.h>
#include<netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#include <errno.h>
#include <exception>
using namespace std;
using std::exception;
int main(int argc,char *argv[]){
int ...
I have a piece of code which uses Boost threads to speed up the calculation, but I need to debug it and want to run them in series, not in parallel. How do I do that?
...
Hello,
I was looking up the keyword volatile and what it's for, and the answer I got was pretty much:
It's used to prevent the compiler from optimizing away code.
There were some examples, such as when polling memory-mapped hardware: without volatile the polling loop would be removed as the compiler might recognize that the condit...