Suppose I define two arrays, each of which have 2 elements (for theoretical purposes):
char const *arr1[] = { "i", "j" };
char const *arr2[] = { "m", "n" };
Is there a way to define a multidimensional array that contains these two arrays as elements? I was thinking of something like the following, but my compiler displays warnings ab...
I have a list:
list<Unit *> UnitCollection;
containing Unit objects, which has an accessor like:
bool Unit::isUnit(string uCode)
{
if(this->unitCode == uCode)
return true;
else
return false;
}
How do I search my UnitCollection list by uCode and return the corresponding element (preferably and iterator).
In ...
Following the advice of this page, I'm trying to get shared_ptr to call IUnknown::Release() instead of delete:
IDirectDrawSurface* dds;
... //Allocate dds
return shared_ptr<IDirectDrawSurface>(dds, mem_fun_ref(&IUnknown::Release));
error C2784: 'std::const_mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(Result (_thiscall _Ty::* )...
So, I have this code fragment:
int * iPtr ;
int * jPtr ;
int i = 5, k = 7;
iPtr = &i;
jPtr = iPtr ;
I have just started learning about pointers, and need to get some doubts cleared.
is jPtr now essentially also pointing at i?
I know I can change the value of i by using *iPtr, but how can I change the value of the object being pointe...
I am parsing using a pretty large grammar (1.1 GB, it's data-oriented parsing). The parser I use (bitpar) is said to be optimized for highly ambiguous grammars. I'm getting this error:
1terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
dotest.sh: line 11: 16686 Aborted bitpar -p -b 1...
I have this code fragment
int i = 5;
int k = 7;
int * iPtr;
int * jPtr;
int * kPtr;
iPtr = &i;
kPtr = &k;
I am required to swap i and k using the pointers. This is how I'm doing it:
*jPtr = *kPtr ;
*kPtr = *iPtr ;
*iPtr = *jPtr ;
Is this the best way to do it, or is there a better way?
...
In Java you can do this:
long now = (new Date()).getTime();
How can I do the same but in c++ ?
...
I am working on an idea that involves getting a full capture of the screen including windows and apps, analyzing it, and then drawing items back onto the screen, as an overlay.
I want to learn image processing techniques and I could get lots of data to work with if I can directly access the Windows screen. I could use this to build aut...
I have a problem regarding multiple inclusion of header file in C++ code.
say for example, i have three class X,Y,Z. X and Y are derived from Base class Z. And i want to create an instance of X in Y. The code will go like this.
class Z{some code}
class X:public Z{some code};//here #include header of class Z added
class Y:public Z //...
I need to process a list of files. The processing action should not be repeated for the same file. The code I am using for this is -
using namespace std;
vector<File*> gInputFileList; //Can contain duplicates, File has member sFilename
map<string, File*> gProcessedFileList; //Using map to avoid linear search costs
void processFile(Fi...
in c++ i have following code
class Foobar{
public:
Foobar * operator()(){
return new Foobar;
};
My quesion is how to call the ();
if i do Foobar foo() the constructor gets called
i am confused about behaviour of ()
can some explain me
...
I have a SpecialisedRedBlackTree class that is templated.
My Month class is not.
In my Month class I have a private member which is an instance of SpecialisedRedBlackTree:
SpecialisedRedBlackTree<Day> m_windSpeedTree;
As you can see it will take the Day class/object (please correct me on any terms I get wrong).
In my Month class, I...
Note: The original was worded in quite a confusing manner. I tried to rewrite it while maintaining the original intent. -George
I need to send a request using GET/POST method to a server and check its response. I need some code in C/C++ to check whether my request was successful or not.
...
I know my gut reaction to global variables is "badd!" but in the two game development courses I've taken at my college globals were used extensively, and now in the DirectX 9 game programming tutorial I am using (www.directxtutorial.com) I'm being told globals are okay in game programming ...? The site also recommends using only structs...
I'm doing stuff related to parsing huge globs of textfiles, and was testing what input method to use.
There is not much of a difference using c++ std::ifstreams vs c FILE,
According to the documentation of zlib, it supports uncompressed files, and will read the file without decompression.
I'm seeing a difference from 12 seconds using ...
Hi,
In my C++ project when I have to go for the inclusion (#include "myclass.h") of header files?? And when I have to go for forward declaration of the class (class CMyClass;) ?? Any suggestions regarding this are welcome.
...
Hi Guys,
I m constructing a C++ program in which I need to handle SIGSEGV and Signal handler should be able to print the Back Trace.
Can any one help in this.
Regards
...
What potential memory leaks won't an implicit destructor handle? I know that if you have anything stored on the heap it won't handle it, and if you have a connection to a file or a database, that needs to be handled manually. Is there anything else? What about, say, non-base data types like vectors?
Also, in an explicit destructor, need...
It seems winpcap can't be used to do this kind of job(ref),
then which library to use alternatively?
...
One of my specific dependent library is built with /ML. How to rebuil it with /MD?
Thanks in advance!
...