c++

how to know if a packet sniffed is accessed from a website directly and not linked?

is there any way to know if a certain tcp segment which has a request message to a server is directly accessed by a user through a browser. not just that its linked by the browser itself to complete the requested page. like for example, a web page with images, when one browses this page, the sniffer tends to get all this urls including ...

I need help with this ogre dependent header (Qgears)

I'm 2 errors away from compiling Qgears. (Hacked Version of the Final Fantasy VII Engine) I've messed with the preprocessors to load the actual location of the ogre header files. Here are the errors: ||=== qgears, Debug ===| /home/cj/Desktop/qgears/trunk/project/linux/src/core/TextManager.h|48|error: invalid use of ‘::’| /home/cj/Desk...

Deleting an std::map (Visual C++)

Hi, I have a pointer to a map that I am trying to delete (this map was allocated with new). This map is valid I think, when I hover on it while debugging, it shows pMap: [0]() .. When I try to delete this empty map, my app just quits and I get a First-chance exception at 0xsomelocation in myapp.exe: 0xsomenumber: The object invo...

C++ equivalent for java final member data

First, my latest coding is Java, and I do not want to "write Java in C++". Here's the deal, I have to create an immutable class. It's fairly simple. The only issue is that getting the initial values is some work. So I cannot simply call initializes to initialize my members. So what's the best way of creating such a class? And how c...

__attribute__((format(printf, 1, 2))) for MSVC ?

With GCC, I can specify __attribute__((format(printf, 1, 2))) , telling the compiler that this function takes vararg parameters that are printf format specifiers. This is very helpful in the cases where I wrap e.g. the vsprintf function family. I can have extern void log_error(const char *format, ...) __attribute__((format(printf, 1, ...

Alternative way to capture the screen? (c++, windows OS)

keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY, 0); keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); HBITMAP h; OpenClipboard(NULL); h = (HBITMAP)GetClipboardData(CF_BITMAP); CloseClipboard(); ... normally this works well. but if the foreground window changes and locks the clipboard then it can't open ...

C++ Lib/Headers in Emacs

Hi, Where could I find C++ libraries in my emacs? I have already installed emacs on my computer and already using it lately. I just want to add boost libraries in emacs so I could use them. ...

Reading from the serial port from C++ or Python on windows

Hi all, I need to read the serial port from windows, using either Python or C++. What API/Library should I use? Can you direct me to a tutorial? Thanks! ...

How to mix Qt, C++ and Obj-C/Cocoa

Hi, I have a pure C++/Qt project on a Mac, but I now find that I need to call a few methods only available in the Cocoa API. Following instructions listed here: http://el-tramo.be/blog/mixing-cocoa-and-qt I have a C++ class implementation in a ".m" file. As a test, my "foo.m" file contains the following code (relevant #include methods...

Check for derived type (C++)

How do I check at runtime if an object if of type ClassA or of derived type ClassB? In one case I have to handle both instances separately ClassA* SomeClass::doSomething ( ClassA* ) { if( /* parameter is of type base class */) { } else if { /* derived class */ ) { } } Maybe I could say that the derived class ClassB has s...

Overloading << operator and recursion

Hi, I tried the following code: #include <iostream> using std::cout; using std::ostream; class X { public: friend ostream& operator<<(ostream &os, const X& obj) { cout << "hehe"; // comment this and infinite loop is gone return (os << obj); } }; int main() { X x; cout << x; return 0; }...

Global or pointer in managed C++ for customized class

My project has both managed & unmanaged code. I wrote a class cIVR in managed code, while defining it in an unmanaged cpp file. The project has been working fine for some time. Now I need to call a member function of one of objects in array 'arrChannels' from another function in the same file. During array definition it's not allowing...

conditional compilation statement in limits.h

I am not able to understand the following statement from the file limits.h. What is the use of this statement and what does it accomplishes? /* If we are not using GNU CC we have to define all the symbols ourself. Otherwise use gcc's definitions (see below). */ #if !defined __GNUC__ || __GNUC__ < 2 ...

c++ variable initialization in a class to send it using mpi

Hello Everybody, I got stuck in a programming task. I want the elements of my stl vector to be placed in a contiguous memory to send it with MPI_Send() routine. here is an example: class Tem { //... private: vector<double> lenghtVector (4500);//this gives a compilation error but I need to have a fixed sized vector }; how can ...

Segmentation fault from std::_Rb_tree_const_iterator<Type>::operator++

I get a segmentation fault when iterating over a set. The stack trace points to std::_Rb_tree_const_iterator<Type>::operator++ std::_Rb_tree_increment() but I get nothing more informative. The iterator is over a set returned by a function for (FactSet::factset_iterator fact_it = (*binSet_it).getDependencyGraph().getExtentionalFactSe...

Error in using vector pointer in a function

I have this code, but it won't compile and i can't understand what is wrong - i guess the pointering of the vector is not correct. My idea was to collect some numbers in main() and store them in a vector and array, and then pass the memory address of them to a function, and using a pointers to print the data stored. I came up with this...

typecasting to unsigned in C

int a = -534; unsigned int b = (unsigned int)a; printf("%d, %d", a, b); prints -534, -534 Why is the typecast not taking place? I expected it to be -534, 534 If I modify the code to int a = -534; unsigned int b = (unsigned int)a; if(a < b) printf("%d, %d", a, b); its not printing anything... after all a is less than b?? ...

CRecordset AddNew produces exception

Hi all, I have a C++ class derived from CRecordset used to add registers to a .mdb file. When my class calls CRecordset::AddNew I get an exception during the execution of AddNew. I use the following code to open the recordset and add the new register: if (Open(CRecordset::dynaset, L"SELECT * FROM Alumnos", CRecordset::none)) { if (Ca...

Transferring signature of the method as template parameter to a class

Hey! I'd like to create a template interface for data-handling classes in my projects. I can write something like this: template <class T> class DataHandler { public: void Process(const& T) = 0; }; Then, suppose, I define a class this way: class MyClass: public DataHandler<int> { void Process(const int&) { /* Bla-...

Windows Spooler Events API doesn't generate events for network printers

the context i use Spooler Events API to capture events generated by the spooler when a user prints a document ie. FindFirstPrinterChangeNotification FindNextPrinterChangeNotification the problem When I print a document on the network printers from my machine no events are captured by the monitor (uses the fuctions above) Notice E...