With using namespace I make the whole contents of that namespace directly visible without using the namespace qualifier. This can cause problems if using namespace occurs in widely used headers - we can unintendedly make two namespaces with identical classes names visible and the compiler will refuse to compile unless the class name is p...
I'm iterating over a vector and need the index the iterator is currently pointing at. AFAIK this can be done in two ways:
it - vec.begin()
std::distance(vec.begin(), it)
Which one is better or preferred and why?
...
To understand the problem,let us consider these examples first:
46 = (22)6 = 212 = (23)4 = 84 = 163 = 4096.
Thus,we can say that 46,212,84 and 163 are same.
273 = 39 = 19683
so, both 273 and 39 are identical.
Now the problem is, for any given pair of ab how to comput...
After seeing this question, I got to thinking about the various challenges that blind programmers face, and how some of them are applicable even to sighted programmers. Particularly, the problem of reading source code aloud gives me pause. I have been programming for most of my life, and I frequently tutor fellow students in programming,...
I think that stackoverflow is rendering me even lazier than usual, but...
The problem is simpler than knapsack (or a type of it, without values and only positive weights). It consists on checking if a number can be a combination of others, and the function shall return true or false.
Ex: 112 and a list with { 17, 100, 101 } should retu...
What's a good existing class/design pattern for multi-stage construction/initialization of an object in C++?
I have a class with some data members which should be initialized in different points in the program's flow, so their initialization has to be delayed. For example one argument can be read from a file and another from the network...
The step is:
I have been running a service program with UAC for mapping network drive using function WNetAddConnection2, then it was successful.
I ran another program with privilege of administrator(run as administrator) to call function GetFileAttribute to get network drive's attribute, however, it was returned 0xffffffff and error cod...
Hi,
I am passing a value to copy constructor as a reference, but an infinite loop is being invoked.
Here's my class:
class Vector2f{
private:
GLfloat x;
GLfloat y;
public:
Vector2f();
Vector2f(const GLfloat _x, const GLfloat _y);
Vector2f(const Vector2f &_vector);
~Vector2f();
};
Here's implementation of me...
Hi,
I have a boost multi index container thus.
using namespace boost::multi_index;
template < typename O >
class Container
{
public:
multi_index_container<
O,
indexed_by<
ordered_unique<
const_mem_fun< O, std::string, &O::name >
>
>
> _container;
};
As you can se...
I have been working through the asio ssl examples (linked below). Despite by best efforts I have been unable to link openssl into the boost example. The output from ld is that ld is missing symbols from libssl.a. The thing that I can not figure out is that I found all the symbols in libssl.a with nm that ld says are missing. I suspect I ...
Recently I've time off of school for a few days and wanted to do a small program(s) experiment in c++ dealing with memory address.
I wanted to see is that if a currently running program (Let call it Program A) that created a pointer to an int object in the heap, can be seen by another program and be modified (Program B).
So for Progr...
I am writing two lines in memory using CMemFile::Write():
void CLISTCTRLDlg::Export(LPTSTR *pBlock)
{
CMemFile outMem(32768);
CString csHeader = _T("EmpId EmpName EmpAddress\n");
outMem.Write(csHeader.GetBuffer(0), csHeader.GetLength());
CString csInfo = _T("1 TestName TestAddress\n");
outMem.Write(csInfo.GetBuffer(0), csInfo.Get...
I am in the process of developing a application which displays the dialogues depending on the OS Language(Windows 2008/Vista/Windows7). How I can get the OS language using C++ or Windows APIs.
Thanks in advance
Santhosh
...
I have been reading an article about C++ interfaces (http://accu.org/index.php/journals/233) and I am completely lost at the part where it says all the virtual member functions should be made private (the section titled "Strengthening the Separation"). It just does not make sense to me at all.
According to the author, the code is like t...
Hi,
I maintain an application written in Borland C++ 6. This app is using SQLite database.
I am now extending it, so it can be used by unprivileged users, and so I had to move the database file to the home user directory. Unfortunately some of users have Polish national characters in their names, such as ą,ć,ę and some more. The syst...
Hello,
I generated some Boost librairies with bjam, and I get many symbolic links.
For date_time :
libboost_date_time-gcc41-mt-1_39.a
libboost_date_time-gcc41-mt-1_39.so -> libboost_date_time-gcc41-mt-1_39.so.1.39.0
libboost_date_time-gcc41-mt-1_39.so.1.39.0
libboost_date_time-gcc41-mt.a -> libboost_date_time-gcc41-mt-1_39.a
libbo...
I am trying to use _CrtDumpMemoryLeaks() to display memory leaks in my programs.
But it does not display anything except for returning 0 in case of no memory leaks and 1 in case there is a leak.
The link here shows the output should be like:
Detected memory leaks!
Dumping objects ->
D:\VisualC++\CodeGuru\MemoryLeak\MemoryLeak.cpp(67) ...
I have to write an OpenOffice add-on (in Java) which communicates with DCOM server of some closed-source application. The major problem is that, I don't have any documentation about server's Interfaces .
All I have is a VB/C++ SDK kit for the Application. SDK contain a library in dll and a bunch of *.tlb files. In SDK documentation ther...
Hi,
I have generated a long sequence of bytes which looks as follows:
0x401DA1815EB560399FE365DA23AAC0757F1D61EC10839D9B5521F.....
Now, I would like to assign it to a static unsigned char x[].
Obviously, I get the warning that hex escape sequence out of range when I do this here
static unsigned char x[] = "\x401DA1815EB56039.....";...
I found a few articles on interacting with the MS-Word spell-checker from C# and managed C++ using .NET.
(For anyone interested: this and this)
But I couldn't find anything comparable on doing it through standard unmanaged C++ in an MFC app, using COM. I assume the .NET examples are actually using COM meaning it's possible, but is it l...