c++

C++ for Wireless Sensor Networks

Similar to: Why are RTOS only coded in C, but: Besides the numerous myths about C++, why is it not used as much as C/nesC (TinyOS) for WSN? Knowing C++ can be used for Simulating Wireless Sensor Networks with OMNeT++ it is hard not to think that it can also be used in real-time embedded systems as C is to accomplish event handling. I ...

Conversion and comparison of microseconds and milliseconds

How can I convert microseconds to milliseconds and make it possible to compare timestamps by substraction? Example: int t1 = (int)timeGetTime(); int t2 = (int)timeGetTime()+40; // now t1 - t2 < 0 which means that t1 < t2. This logic won't work if you divide time values by 1000, to convert microseconds to milliseconds. ...

C++ pointers to class instances

I have an (for C++ programmers better than me) simple problem with classes and pointers. I thought about posting example code describing my problem but I found it easier to just explain it in words. Assuming I have three classes: Class A: The main class - it contains an instance of both B and C. Class B: This class contains a method t...

Holding a generic type's instance - C++

I have a tree_node class and a tree class. template<typename T> class tree_node { public: tree_node(const std::string& key_, const T& value_) : key(key_), value(value_) { } private: T value; std::string key; }; template<typename T> class tree { public: tree() : root(new tree_node<T>("", ???)) { } private: ...

What are the possible reasons the system() function can not find the executable?

if( system("tail -500 log.txt") == -1) { //Error calling tail.exe on log //errno is a system macro that expands int returning //the last error. strerror() converts the error to it's //corresponding error message. printf("Error calling tail.exe with system(): %s",strerror( errno )); } System() is c...

Win32 API timers....

I was using the system timer (clock() function, see time.h) to time some serial and USB comms. All I needed was approx 1ms accurace. The first thing I noticed is that individual times can be out (plus or minus) 10ms. Timing a number of smaller events led to less accurate timing as events went by. Aggregate timing was slightly better. Aft...

Drag listbox Notifiaction messages and Re-Ordering

I am able to re-order my list box items using a mouse. I am only using one listbox. The dialog has few combo boxes and other stuff too, so listbox is a child control of that Dialog.For example I can drag and drop or move item5 to the 2nd position in the list or anywhere using my mouse. However when I do that, I want my grid to get update...

Is std::vector copying the objects with a push_back ?

After a lot of investigations with valgrind, I've made the conclusion that std::vector makes a copy of an object you want to push_back. Is that really true ? A vector cannot keep a reference or a pointer of an object without a copy ?! Thanks ...

opengl problem with QT

Hey, I'm using QT with opengl to make a chart in order to use it in different simulated physical experiments, but I'm facing the following problem. I can't see my chart line unless I minimized my form window and then maximized it, and I should do that all the time as long as my line chart is being drawn in order to get the full result!! ...

Splitting a string by whitespace in c++

Possible Duplicates: C++: How to split a string? Splitting a string What is the best way to go about splitting a string up by whitespace in c++? I'd like to be able to split it based on tab, space, etc. and of course ignore multiple tabs/spaces/etc. in a row as well as not have issues with having those things at the end. U...

What is the best tutorial for learning MPI for C++?

Hi, I plan to use MPI for my C++ code. I have installed MPICH2 on my computers. But I do not know much about MPI and hope to find some materials to read. I hope you experts can recommend some good materails to me. Any advice will be appreciated. ...

Find boundaries of an array of objects with only the boundaries of the objects

New Programmer here. Trying space invaders. I have a 2 dimensional array of objects stored in a one dimensional array (using modulo to determine rows and columns). Each object will return its boundaries in graphical space. I need to determine the boundaries (top, bottom, left, right) of the whole array for collision detection. I feel l...

Debugged Program Window Won't Close

Hi, I'm using VS 2008 on a 64-bit XP machine. I'm debugging a 32-bit C++ DLL via a console program. The DLL and EXE projects are contained in the same SLN so that I can modify the DLL as I test. What happens is that every once in a while I kill the program with Debug | Stop Debugging (Shift-F5). VS stops the program, but the console win...

Disjoint Set ADT Implementation in c++

Hay Dear! I have problem in implementing disjoint set ADT in c++ due to the fact that our teacher only explained the union and find operations. I have full concept of union and find but still I am confused about how to implement. Please give me an idea , also explain what should be the interface of this data structure. Explain this data...

Creating a prefixed sequence in one line

Given the initialized variables unsigned a, unsigned b with b > a and std::vector<std::string> strings of size b-a. How can I fill strings with the elements e.g. "x3" "x4" "x5" "x6" (in case a=3 and b=7) for arbitrary a and b with one C++ command (meaning one semicolon at all :))? ...

Documenting namespaces with Doxygen

I'm having issues with Doxygen recognizing namespaces and modules. I believe the issue surrounds whether to place the \addtogroup within the namespace or outside the namespace. Example 1, outside the namespace: /*! * \addtogroup Records * @{ */ //! Generic record interfaces and implementations namespace Records { //! Describe...

Object construction/Forward function declaration ambiguity

Observation: the codes pasted below were tested only with GCC 4.4.1, and I'm only interested in them working with GCC. Hello, It wasn't for just a few times that I stumbled into an object construction statement that I didn't understand, and it was only today that I noticed what ambiguity was being introduced by it. I'll explain how to ...

scons setting CXXFLAGS in one module affects another one

in dirA/SConscript I have: Import('env') probeenv = env.Clone() probeenv['CXXFLAGS'] += ['-fno-rtti','-Wnon-virtual-dtor'] ... stuff that uses probeenv in dirB/SConscript I have Import('env') sipenv = env.Clone() ... stuff that uses sipenv Now, c++ files in dirB that gets compiled, gets the CXXFLAGS from dirA - how come ? This doe...

Move C++ app with Boost from Linux to Windows with Visual Studio 6

I made a small program with Boost in Linux 2 yrs ago. Now I want to make it work in Windows. I found there are few .a files in my libs folder. I am wondering how to make it works in Windows? do I need to build Boost in Windows to get library or I can download somewhere? I am using Visual Studio 6. ...

Which IDE for C++ software can I use for targeting Windows, Linux and OSX?

Hello I was reading today question on IDEs fo C++, and there are very good ones like Netbeans. My question is about creating a software in C++ on Windows Environment, but let users install and run my software also on Linux and OSX. Does netbeans has a compiler to do the job, or is there any good IDE which has a compiler for targeting...