c++

function returning an iterator of vector

I have this new class Seq that inherits vector and has some additional features. I can use all methods of vector with Seq. Having this data structure: Seq< vector<int> > sweepEvents; I want to have a function that takes an element vector edge search for it in sweepEvents and returns the iterator to the position of the found element i...

does assignment operator work with different types of objects?

class A { public: void operator=(const B &in); private: int a; }; class B { private: int c; } sorry. there happened an error. is assignment operator valid ? or is there any way to achieve this? [There is no relation between A and B class.] void A::operator=(const B& in) { a = in.c; } Thanks a lot. ...

How to programmatically check Internet bandwidth in VC++?

I need to find the bandwidth available at a particular time. The code must be developed in Visual C++ or in .Net family . If anyone knows how, please help me out. ...

Is it possible to access private members of a class?

Is it possible to access private members of a class in c++. provided you don't have a friend function and You don't have access to the class definition ...

How can I change to another directory in C++?

I am writing a program in C++ where I have 500 folders, each containing one text file. I want to read each text file from each folder in C++. How can I accomplish this? ...

How to compile C# application with C++ static library?

Hello, I turned my C++ Dynamic link library into Static library just to acquire more knowledge. My question is how can I use the .obj file to compile both projects with C# express/MS visual studio? ...

Writing a MySQL UDF using C++ STL functionality

There is a statement in the MySQL Docs (http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html) that is bothering me: "A UDF contains code that becomes part of the running server, so when you write a UDF, you are bound by any and all constraints that otherwise apply to writing server code. For example, you may have problems if you at...

sizeof(*this) gives wrong value

I have a class, C. C has a member variable declared as: bool markerStart; From within C a call to sizeof(*this) gives a value of 0x216 bytes. Elsewhere within C, I do: markerStart = false; Rather than setting markerStart to false, this call is actually clobbering the start of the next class in memory! Looking at the disassembled code...

Waiting for pthread_create to finish without using pthread_join

I want to halt one thread till another thread has finished initializing without using pthread_join. I tried using a join but it leads to a deadlock due to some asynchronous inter-thread communication system that we have. Right now, I'm using a (custom) lock to achieve this. In Thread 1: lock_OfflineWorker.Lock() if (pthread_create(&tid...

bandwidth throttling with Qt

hi, I'm using the QNetworkAccessManager to download files from the web, it provides an easy API to the task. But I wish to add a download rate limit to the class, so all http replies won't exceed that limit (I see no reason to limit the requests). I've googled abit and found an interesting post here. But what it does is subclass QTcpSo...

Changing behavior of an object at runtime

How can be changed the behavior of an object at runtime? (using C++) I will give a simple example. I have a class Operator that contains a method Operate. Let’s suppose it looks like this: double operate(double a, double b) { return 0.0; } The user will give some input values for a and b, and will choose what operation to perform let’s s...

Using pthread condition waits in a structure

I previously inquired about synchronizing two threads without using pthread_join and I was able to resolve it using pthread_cond_wait and pthread_cond_signal. I've written a small struct to bundle this functionality into a single place: struct ConditionWait { int i_ConditionPredicate; pthread_mutex_t lock_Var; pthread_c...

How to Enforce C++ compiler to use specific CRT version?

I am using VS2008 for developing a COM dll which by default uses CRT version 9 but I am using TSF (Text service framework) that is not compatible with the new CRT. I think the solution is to use the compatible one so how can I specify the CRT version? ...

Beginner Issue with C++ Intellisense and Error Checking?

Using Visual C++ 2008. First time, I'm experimenting in crossing over from C# and wanted to try my hand at it. I have not changed base settings much, other than a few things like smart block and maybe a few colors. Because I'm at level ZERO on c++ knowledge all the googling I've done is over my head. Issue with intellisense and error lis...

gprof and arguments to executable

when using gprof: gprof options [executable-file [profile-data-files...]] [> outfile] if you have options to pass to the executable like: gprof a.out --varfred=32 then gprof assumes that i am passing an invalid option to gprof instead of the a.out. Any way to get around this? ...

Iterator access performance for STL map vs. vector?

What is the performance difference between using an iterator to loop through an STL map, versus a vector? I'd like to use the map key for insertion, deletion, and some accesses, but I also need to do regular accesses to every element in the map. ...

Help with OSSpinLock* usage to replace a while(true) {sleep(1);}

I am maintaining a carbon C++ application on OS X. There is a "spin lock" in one of the objects in the code that looks like this, while ( mState != RELEASED ) { sleep( 1 ); } There is a post render maintenance callback that is fed to AudioUnitAddRenderNotify() that would set the mState of these various objects. I was thinking about ...

How do you "decode" Visual Studio Link Errors?

I'm not very experienced in C++, and when I have to work with another library and I get link errors, I'm completely in the dark on what the compiler is trying to tell me (other than it can't find something reference somewhere). Are there any good links that describe, in detail, the meaning of the symbols and characters in a link error m...

c++ profiling/optimization: How to get better profiling granularity in an optimized function

I am using google's perftools (http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html) for CPU profiling---it's a wonderful tool that has helped me perform a great deal of CPU-time improvements on my application. Unfortunately, I have gotten to the point that the code is still a bit slow, and when compiled using g++'s -O3 ...

How create file in C++ in a specific place in the PC

Hey all, I have a problem, I don't know how to create a file in C++ in a specific place in the PC. For example a file (.txt) in C:\file.txt. Can anybody help me? Thank you :) ...