c++

Best practice for C++ function commenting

Is there an accepted best practice for commenting functions? I only know of the doxygen style but it is not officially supported by C++ like Javadocs is for Java so just wondering what is best. ...

Which kind of cast is from Type* to void*?

In C++ for any data type I can do the following: Type* typedPointer = obtain(); void* voidPointer = typedPointer; which cast is performed when I assign Type* to void*? Is this the same as Type* typedPointer = obtain(); void* voidPointer = reinterpret_cast<void*>( typedPointer ); or is it some other cast? ...

Why can't I multi-declare a class

I can do this extern int i; extern int i; But I can't do the same with a class class A { .. } class A { .. } While in both cases no memory is being allocated. ...

Are virtual destructors inherited?

If I have a base class with a virtual destructor. Has a derived class to declare a virtual destructor too? class base { public: virtual ~base () {} }; class derived : base { public: virtual ~derived () {} // 1) ~derived () {} // 2) }; Concrete questions: Is 1) and 2) the same? Is 2) automatically virtual because of its...

RS-232 confusion under C++

What's the problem in given code? Why it is not showing the output for rs232 when we connect it by the d-9 connector with the short of pin number 2 & 3 in that? #include <bios.h> #include <conio.h> #define COM1 0 #define DATA_READY 0x100 #define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00) int main(void) { int in, out, status; bios...

how to supress indivual warnings in C++?

First of all, sorry if this is an obvious question, but I'm rather new to C++. Also, this code is not originally mine, but I am trying to clean it up. I'm looking for a compiler independent way to surpress warnings (preferably) for a specific line. I've got the following code: int MPtag::state_next( int i, int s ){ #if NGRAMS==2 ...

what does openframe works mean(ofFill(),ofRec()...etc) any similar function can i find in opencv

what does openframe works mean(ofFill(),ofRec()...etc) any similar function can i find in opencv ...

Why is my adjacency list showing duplicate edges?

#include <iostream> using namespace std; struct node { int v; node* next; node (int x, node* t) { v = x; next = t; } }; typedef node *link; int **malloc2d(int, int); void printMatrix(int **, int); link *convertToList (int **, link *, int); void printList (link * a, int size); // program begins fun...

Input output communication between two programs

I have a third party java program called kgsgtp.jar which need to communicate with my own C++ (but mainly just C) program. The documentation for the java program states: ===================== You just need to make sure that stdin for kgsGtp it connected to the engine's output and stdout for kgsGtp is connected to the engine's inpu...

cygwin multi-threaded c++ debugging with netbeans

When I debug my program with netbeans using cygwin's g++, when it receives a sigabrt, I can't see my code anywhere in the call stack of any of the threads. Most of them are at ntdll!RtlEnableEaryCriticalSectionEventCreation() and one in RaiseException(). The problem is that after these there are only either some win32 functions without a...

ofstream - detect if file has been deleted between open and close

I'm wriiting a logger on linux. the logger open a file on init. and write to that file descriptor as the program run. if the log file will be deleted after the file descriptor was created, no exception/error will be detected . i have tried: out.fail() !out.is_open() i have google this and find this post . http://www.daniweb.com/forum...

Why is (void) 0 a no operation in C and C++?

I have seen debug printfs in glibc which internally is defined as (void) 0, if NDEBUG is defined. Likewise the __noop for Visual C++ compiler is there too. The former works on both GCC and VC++ compilers, while the latter only on VC++. Now we all know that both the above statements will be treated as no operation and no respective code w...

Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it?

Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides? edit: I appreciate the suggestions for different ways to receive packets, but I want to implement packet injection into Wiresha...

C++ Operator overloading example

Hi! Well, I'm new to operator overloading, and I found this problem. Instead of documenting myself, I prefer to ask you :D The point is, I know how to do simple operator overloading, but I'm facing problems with stacking operators. I'll try to put a relatively simple example: struct dxfdat { int a; string b; /* here is the question...

LD_DEBUG=files for Windows Visual Studio?

I'm quite stuck on a ddl loader problem under Windows Visual Studio 2009 C++. I have a framwork which loads plugins as DLL files, unfortunatly I have no sourcecode access to the framework. The dependency walker doesn't show any errors, but the framework just says "dependencies not found" when loading the plugin. I'm quite unfamiliar wit...

Printf and scanf work without stdio.h, why?

Possible Duplicate: Why #include <stdio.h> is not required to use printf()? Both printf and scanf have been declared in stdio.h. But they work even without that, dropping just a warning message? What's the theory behind this? ...

What's the point of "typedef sometype sometype" ?

Lately I've run into the following construction in the code: typedef sometype sometype; Pay attention please that "sometype" stands for absolutely the same type without any additions like "struct" etc. I wonder what it can be useful for? UPD: This works only for user defined types. UPD2: The actual code was in a template context l...

C++ How to store collection of templates objects regardless of tempate

I have a problem with implementing database table library. I have a class Column storing different types. template <class T> class Column : iColumn<T> { ... } Table is composed of columns, so I need a collection of them (map with string name as a key and column as value). How shall I implement one collection of all table's columns r...

Asynchronous winsock server wrapper, CPU lagging - C++.

Hello! I am trying to write a Server application wrapper, as I would with any application and I've searched for over a week for a at least decent guide or tutorial on asynchronous sockets( this wrapper has to be asynchronous ) and so far what i could do is this: #ifndef _SERVER_H #define _SERVER_H #include "asynserv.h" // header file w...

Find all drops of a manager account

When i run the command :- drops = Dropio::Drop.find_manager_drops(your_manager_api_token) it throws an error "Invalid manager account or manager api token.". Whenever i am taking manager api token from the following location:- firstly login with proper credentials > Settings > Premium API Access "Premium Api Access" provides two th...