c++

C++ DAL Design - Include Foreign Key Table as Composite Object

Hi, I recently posted this C++ DAL question about how best to design a 'loadCar' method in a C++ DLL, with the consensus being that 'bool DAL::loadCar(int id, Car&) {}' would be the best signature to use. Now, it so happens that in a lot of our use cases the client code will often want to retrieve the car's manufacturer with the car ob...

Why am I able to make a function call using an invalid class pointer

In below code snippet, although pointer is not initialized the call is still made successfully temp *ptr; ptr->func2(); Is it due to C++ language property, or it is VC++6 compiler which is foul playing? class temp { public: temp():a(9){} int& func1() { return a; } bool func2(int arg) { if(arg%2==0...

C++ deprecated conversion from string constant to 'char*'

I have a class with a private char str[256]; and for it i have an explicit constructor, explicit myClass(const char *func) { strcpy(str,func); } i call it as, myClass obj("example"); when i compile this i get the following warning: deprecated conversion from string constant to 'char*' can anyone please provide a pointer to this...

Thread Safe Access to Data Shared Between Objects

I'm something of an intermediate programmer, but relatively a novice to multi-threading. At the moment, I'm working on an application with a structure similar to the following: class Client { public: Client(); private: // These are all initialised/populated in the constrcutor. std::vector<struct clientInfo>...

C++ - when are non-pointers class member destroyed?

Suppose I have this code... class GraphFactory : public QObject { private: QMap<QString, IGraphCreator*> factory_; public: virtual ~GraphFactory(); }; GraphFactory::~GraphFactory() { // Free up the graph creators QMap<QString, IGraphCreator*>::iterator itr; for (itr = factory_.begin(); itr != factory_.end(); itr++)...

Linux ioctl -> how to tell if current IP was obtained by dhcp

Hello all, I'm fiddling with the sockets ioctl's to get the current interfaces setup and I can already get the IP, interface name, netmask and check if the interface is up or down, (I just do IOCTl to SIOCGIFCONF, SIOCGIFNETMASK and SIOCGIFFLAGS). I am looking for a way to tell if my current IP address was obtained through dhcp or if ...

UDP multicast using winsock API differences between XP and Vista

Hi, It seems to be that the implementation required to set up a UDP multicast socket has changed between windows XP and windows vista. Specifically: Under windows XP, you must call bind() before you can reference any multicast-specific socket options. However, under windows vista, you must not call bind() when dealing with multicast s...

edit ListView from C++ clr

Hi, I am facing some prob in managed C++, I can fill my ListView , but I am unable to edit specific row at later time I can fill like listView1->View = View::Details; listView1->Columns->Add("S.no",...... ListViewItem^ itmp = gcnew System::Windows::Forms::ListViewItem("100"); ListViewSubItem^ itms1 = gcnew ListViewSubItem(itmp, "12...

separating compilation for to avoid recompilation when I add some debugging to .h file

I have a .h file which is used almost throughout the source code (in my case, it is just one directory with. .cc and .h files). Basically, I keep two versions of .h file: one with some debugging info for code analysis and the regular one. The debugging version has only one extra macro and extern function declaration. I switch pretty re...

Using taglib in a Qt application

I'd like to get the length of a media file in a qt application i'm building and so i decided to use taglib. This is the methos that is meant to read the length void loadMetaData(QString file) { QByteArray fileName = QFile::encodeName( file ); const char * encodedName = fileName.constData(); TagLib::FileRef fileref = TagLib::...

How do we explain the result of the expression (++x)+(++x)+(++x)?

x = 1 i expect the answer to be 11, but it comes out to be 12. ...

Do I need a mutex for reading?

I have a class that has a state (a simple enum) and that is accessed from two threads. For changing state I use a mutex (boost::mutex). Is it safe to check the state (e.g. compare state_ == ESTABLISHED) or do I have to use the mutex in this case too? In other words do I need the mutex when I just want to read a variable which could be co...

How to set fixed axis intervals with Qt/QwtPlot?

I want to have a plotting widget in my Qt application. Qwt provides such a widget with QwtPlot. However, I can't find any way to only display a certain part of the complete range of my data. Specifically, I want to display spectrums with a frequency range from 0 to 2^14. For the GUI however, only the audible range from ~20-20k Hz is of ...

Mpeg 7 Descriptors in C++

Hello, I need some descriptors of MPEG7 in C/C++. The descriptors are dominant color, color layout, color structure, scalable color, edge histogram and homogeneous texture. Do you know where can I find C/C++ source code for some of these these descriptors? Thanks ...

Initializing temporary aggregate object using curly braces.

Let's say I have a class: class Aggregate { public: int x; int y; }; I know how to initialize an object using curly braces: Aggregate a1 = { 1500, 2900 }; But I can't find a proper syntax to create temporary object and pass it as an argument to some method, for example: void frobnicate(const Aggregate& arg) { // do...

Does anyone have experience with Clipsmm?

Hey Stack Overflowers, I have been looking at using CLIPS as an expert system for a simulator i am working on, and so i had a look at clipsmm. The only problem is that their sourceforge page has broken links and private forums. I was just curious if anyone has had experience with clipsmm (i have learnt how to use CLIPS as a stand alone a...

Converting Unicode to Multibyte

I have smalll problem i want to convert unicode into Multi byte is there any way ...

Delete all items from a c++ std::vector

I'm trying to delete everything from a std::vector by using the following code vector.erase( vector.begin(), vector.end() ); but it doesn't work, help! Update: Doesn't clear destruct the elements held by the vector? I don't want that, as I'm still using the objects, I just want to empty the container ...

Is there a BinaryReader in C++ to read data written from a BinaryWriter in C#?

I've written several ints, char[]s and the such to a data file with BinaryWriter in C#. Reading the file back in (in C#) with BinaryReader, I can recreate all of the pieces of the file perfectly. However, attempting to read them back in with C++ yields some scary results. I was using fstream to attempt to read back the data and the ...

Decryption with AES and CryptoAPI? When you know the KEY/SALT

Okay so i have a packed a proprietary binary format. That is basically a loose packing of several different raster datasets. Anyways in the past just reading this and unpacking was an easy task. But now in the next version the raster xml data is now to be encrypted using AES-256(Not my choice nor do we have a choice). Now we basically ...