c++

Is there any physical part of memory with the address of NULL(0) ?

I know there's an old saying when you want to indicate this specific pointer doesn't point to anything it should be set to NULL(actually 0), but I'm wondering isn't there actually a physical part of memory with the address of NULL(0) ? ...

Is i += ++i undefined behavior in C++0x?

I'm very convinced with the explanation I've found that said that i = ++i is not undefined as far as C++0x is concerned, but I'm unable to judge whether the behavior of i += ++i is well-defined or not. Any takers? ...

How to disable automatic indenting when typing ':' in Visual Studio 2008

When i write a classes constructor typing : to start the initialization list of a C++ constructor Visual Studio indents the line when it is right after a namespace directive. Also when i type :: (scope resolution) Visual Studio indents the line, which i found very annoying since the indentation was correct in the first place and i always...

Direct formula for summing XOR

I have to XOR numbers from 1 to N, does there exist a direct formula for it ? For example if N = 6 then 1^2^3^4^5^6 = 7 I want to do it without using any loop so I need an O(1) formula (if any) ...

how to safely delete multiple pointers

I have got some code which uses a lot of pointers pointing to the same address. Given a equivalent simple example: int *p = new int(1); int *q = p; int *r = q; delete r; r = NULL; // ok // delete q; q = NULL; // NOT ok // delete p; p = NULL; // NOT ok How to safely delete it without multiple delete? This is especially difficult if I...

which server i can embed that support php?

I need to make web application that is acutely desktop application The business logic will be written ( taken from web app) in php and the underlain infra is c++ For that I need some solution to run embed server that support php or to think about some other solution ...

Can I add MFC support to an Existing ATL COM project

I have created a Shell Extension using ATL COM Object . But during creation I haven't added MFC support. Can I change the setting now to add MFC support ...

Memory layout question

Do these two structs have the same memory layout? (C++) struct A { int x; char y; double z; }; struct B { A a; }; Further can I access x, y, z members if I manually cast an object of this to an A? struct C { A a; int b; }; Thanks in advance. EDIT: What if they were classes instead of structs? ...

c++ syntax of create an instance

class class_name instance; class_name instance; The above all work with cl.exe, but is it standard,is it the same with all other compilers? ...

Opengl - what is gl.h - how to write a very simple gl app using newest api

ow to write a very simple gl app using newest api. And what is gl.h where to downlaod it, how to use it ...

Finding eigenvectors of covariance matrix to create 3D bounding sphere

I'm currently in the process of writing a function to find an "exact" bounding-sphere for a set of points in 3D space. I think I have a decent understanding of the process so far, but I've gotten stuck. Here's what I'm working with: A) Points in 3D space B) 3x3 covariance matrix stored in a 4x4 matrix class (referenced by cells m0,m1,m2...

How to Convert CString LPStr

I want to read a value from registry using the following method: char* cDriveStatus=ReadFromRegistry(HKEY_CURRENT_USER,_T(NDSPATH),m_szDriveName); I tried converting using GetBuffer,m_szDriveName.GetBuffer(0) but this again shows error: error C2664: cannot convert parameter 3 from 'wchar_t *' to 'LPSTR' Edit: Declaration of Met...

Is it good practice to make member variables protected?

Asking this question because I feel that member variables of my base will be needed later in derived classes. Is there a drawback of making them protected? EDIT: Edited to better show my intention. EDIT: @sbi : Is this also wrong? This class will be used for error recording and retrieving in other classes. Is it better to derive from ...

How to get the GL library/headers?

#include <gl\gl.h> #include <gl\glu.h> #include <gl\glaux.h> This is an example, but where to get GL headers? ...

Questions every good C/C++ Developer should be able to answer?

I was going through interview questions tag and found those question are quite useful, so in the same spirit, I am asking this question for C and C++ developers What questions do you think good C and C++ programmers should be able to answer? Looking forward for some amazing responses. Please answer questions too, so that people could ...

Why friend function can't be used for overloading assignment operator ?

Hi, Assignment operator can be overloaded using member function but not friend function. Sample code is like below. class Test { int a; public: Test(int x) :a(x) {} friend Test& operator=(Test &obj1, Test &obj2); }; Test& operator=(Test &obj1, Test &obj2)//Not implemented fully. just for test. { return obj1...

How to Notice Close of MySql Server in Qt

When I closed MySql server, how can I understand that mysql server is gone away from my Qt program? Edit: Here my trial: When I close MySql, I get these results, and I can't catch that MySql is closed. My Code Snippet is QSqlQuery query(db); query.exec("SELECT * From RequestIds"); qDebug()<<query.lastError(); qDebug()<<db.lastError(...

adjacency matrix

my question is given an adjacency matrix of a graph and a positive interger n find the number of path of length n between two vertices,i don't know how to convert to programming? somebody can help me. ...

WIN32_FIND_DATA Problems - cFileName

hello, i have a problem with my code ;) hFind = FindFirstFileEx( szPath, FindExInfoMaxInfoLevel, &FindData, FindExSearchNameMatch, NULL , 0); strncpy_s( pszFileName, 280, FindData.cFileName, strlen(FindData.cFileName)); everything seems fine but when i copy the executable to another computer (windows 2003) i get But for pszFileName...

Calling an executable's function code

I have the location/offset of a particular function present inside an executable. Would it be possible to call such a function (while suppressing the CRT's execution of the executable's entry point, hopefully) ? ...