c++

Compiled FreeImage from source. #include FreeImage.h not found.

I have compiled FreeImage 3.10.0 from source at /lib/FreeImage on Mac OS X 10.6. I can see that after compilation these files were copied: /usr/local/lib/libfreeimage-3.10.0.dylib /usr/local/lib/libfreeimage.a /usr/local/include/FreeImage.h CMake cannot find FreeImage, but I cannot even do #include <FreeImage.h> // not found I am...

C++ efficient inheritence of certain methods in child classes

Hi, I find my self repeating a single line of code in child constructors, which are passed two variables. The first of these variables is always used to initiate a protected variable (defined in the parent class). I was wondering if there is a way for me to do that assignment in the parent constructor - which is then inherited, and do t...

Linux multithreading would involve the pthreads library(in most cases) . What is the equivalent library used by MSVC ?

I need to know which are the APIs/library used for multithreading by MSVC . If there are more than one , please let me know which is the most widely used. If my question sounds too naive , its because I've never done threading before , and from my past experience , I know there are people here who can get me started/point me at the righ...

Self-sufficient header files in C/C++

I recently posted a question asking for what actions would constitute the Zen of C++. I received excellent answers, but I could not understand one recommendation: Make header files self-sufficient How do you ensure your header files are self-sufficient? Any other advice or best-practice related to the design and implementation of he...

Why is my printList function not working?

#include <iostream> using namespace std; struct Node { char item; Node *next; }; void inputChar ( Node * ); void printList (Node *); char c; int main() { Node *head; head = NULL; c = getchar(); if ( c != '.' ) { head = new Node; head->item = c; inputChar(head); } cout << head->item...

How do I detect a custom plugin in Firefox/IE/Chrome?

My team wants to build a "plugin" for firefox/chrome/IE. How do I use javascript to detect if this plugin (not extension) is installed? I would like to have a piece of javascript that can detect if a certain plugin is installed. Returns true if installed, returns false otherwise. For example...how do I get a list of plugins, and then ...

Can a thread be pre-empted in the midst of a system call to kernel ?

I'm running 2 threads ( assume they are pthreads for the moment) . Thread_1() makes a user-defined API call which ultimately does some work in the kernel . Thread_2() is totally in user-space. My question is : Can Thread_2() start executing by pre-empting Thread_1() while the API call is in progress , the control is somewhere inside th...

What is comming in IDataObject?

When you implement IDropTarget you must implement this: virtual HRESULT STDMETHODCALLTYPE Drop( /* [unique][in] */ __RPC__in_opt IDataObject *pDataObj, /* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ __RPC__inout DWORD *pdwEffect)=0; I want to know what kind of data...

c++ iterator confusion

I have a vector<list<customClass> > I have an iterator vector<list<customClass> >::const_iterator x When I try to access an member of customClass like so: x[0]->somefunc(), I get errors of a non-pointer type/not found. ...

Preferred implementation of '<' for multi-variable structures

Initially this may seem overly abstract or philosophical, but I am genuinely interested to see if someone has a convincing argument in favor of one implementation over the other. Given operator< for std::pair<T1, T2>, which would be the better implementation: return x.first < y.first || x.first == y.first && x.second < y.second;...

C++ Bus error in SPARC arcitecture

I would like to understand why I am getting a bus error with this code. int main() { int p=34; int *pp= (int *) ((char *)&p+1); cout<<*pp<<"\n"; return 0; } ...

Linking error when compiling C and C++ code with g++

I am integrating a medium-sized (10,000 or so lines) program written in C into a C++ program. I have created a new class, BWAGenome as an interface to the C code, so any access to the C functions is encapsulated. I am compiling everything with the g++ compiler. The .o files are all generated correctly, but when I attempt to link them tog...

Threads and simple Dead lock cure

When dealing with threads (specifically in C++) using mutex locks and semaphores is there a simple rule of thumb to avoid Dead Locks and have nice clean Synchronization? ...

c++ operator overloading

hello .. i'm not sure if what im talking about is an operator overloading question. is it possible to overload keywords in C++?? for example : i need to write loopOver(i=0; ;i++) instead of for(i=0;;i++) ?? is that possible in C++ and i need to have something like 2 addTo 2 instead of 2 + 2 please help thanks in advance ...

How do I write a public function to return a head pointer of a linked list?

class Newstring { public: Newstring(); void inputChar ( char); void display (); int length (); void concatenate (char); void concatenate (Newstring); bool substring (Newstring); void createList (); Node * getHead (); // error private: struct Node { char item; Node *next; }; N...

Networking Method

Hey guys, Iv'e noticed that when I send a complete packet (collect it's data in a buffer and send) it is much slower than sending the packet byte by byte. Will it be okay if I make an online game using this method? ...

C++ - dynamic pointer of array

Hi to all, first i would like to say i am Newbie in C++. As part of my master thesis i am writing a program in C++ which also get as parameters the variables m and d (both integers). Were d is the power of 2 (this means 2^d elements). Parameter m define the number of possible interactions between one element and the total group (2^d el...

Tools for Unix <-> Windows C++ development

I am doing some C++ cross development - been doing that for a while on Windows and recently started on Unix. I suppose what I am after is to simplify Unix development experience - I have a local windows box I do development on, and a remote Solaris box which I use to compile and test code on unix environment. What I do now - I develop...

Difference between %i and %d in printf() for C and C++

what is the difference between %d and %i when used in printf function ? ...

abstract class and using array polymorphically

i'm just reading meyers "More Effective C++ 35 New Ways" - item 33, and he suggest there always to inherit from an abstract base class, and not a concrete. one of the reason he claims, which i can't quite get , is that with inheriting from an abstract class, treating array polymorphically (item 3 in the book) is not a problem. can some...