Hello,
I was recently asked, in an interview, to describe a method to calculate the factorial of arbitrarily large numbers; a method in which we obtain all the digits of the answer.
I have searched various places and asked in few forums. But I would like to like to know if there exists any way to achieve this without using libraries li...
What's wrong with my code?
I tried to compile the code below in the GNU G++ environment and I get these errors:
friend2.cpp:30: error: invalid use of incomplete type ‘struct two’
friend2.cpp:5: error: forward declaration of ‘struct two’
friend2.cpp: In member function ‘int two::accessboth(one)’:
friend2.cpp:24: error: ‘int one::data1’...
I met two explanation of const member function
class A{
public:
...
void f() const {}
...
}
it means it could only access constant members;
it means it does not modify any members;
I think the second one is right. But why does the first one come out? Is there anything to be clarify?
Thanks!
...
Hi,
if I have a source of library written in C/C++ (lets say its libxml2), now I'd like to build it, and link it into the delphi application... I know it is possible, since Delphi Zlib does it ( http://www.dellapasqua.com/delphizlib/ ) ... But my question is, how to prepare those .obj files?
Thanks in advance
m.
...
Using SFINAE, i can detect wether a given class has a certain member function. But what if i want to test for inherited member functions?
The following does not work in VC8 and GCC4 (i.e. detects that A has a member function foo(), but not that B inherits one):
#include <iostream>
template<typename T, typename Sig> ...
Is there any reason not to assume that SIZE_T is a typedef of size_t on Microsoft's Visual C/C++ compilers ? The Windows intsafe.h functions do include safe casting functions from one to the other. Is that just for the sake of completeness or is there any scenario where a static cast could fail to give the expected result ?
...
I have a C++ app that uses wxWidgets. Certain parts of the app differ for 32 and 64 bit hosts. Currently I use sizeof(void *), but is there a better way that uses conditional compilation and is platform neutral?
...
I've been using getaddrinfo for looking up socket addresses for basic socket commands. Recently, though, the addresses it returns to me are for bogus IP addresses, which I have found using inet_ntop. I've tried my code, as well as that provided in Beej's Guide, and they both produce the same results. Here's the code:
struct addrinfo hin...
I search over internet for about 2 hours and I don't find any work solution.
My program have multibyte character set, in code i got:
WCHAR value[1];
_tcslen(value);
And in compiling, I got error:
'strlen' : cannot convert parameter 1
from 'WCHAR [1]' to 'const char *'
How to convert this WCHAR[1] to const char * ?
...
I remember when messing around with Qt seeing something where it was like
class MyForm : QDialog
{
}
Instead of
class MyForm
{
void SetupUi(QDialog* dialog);
}
How do you generate the inherited form?
...
Hi,
here is a quite simple question(I think), is there a STL library method that provides the limit of a variable type (e.g integer) ? I know these limits differ on different computers but there must be a way to get them through a method, right?
Also, would it be really hard to write a method to calculate the limit of a variable type?
...
I want to search some memory range for a specific byte pattern. Therefore, my approach is to build a function
void * FindPattern (std::vector<byte> pattern, byte wildcard,
void * startAddress, void * endAddress);
using the Boyer-Moore-Horspool algorithm to find the pattern in the memory range.
The wildcard byte stays for some sp...
In my code, I want to use a byte-vector to store some data in memory. The problem is, that my current approach uses many lines of code:
std::vector<byte> v;
v.push_back(0x13);
v.push_back(0x37);
v.push_back(0xf0);
v.push_back(0x0d);
How can I shorten this procedure so that I have for example something like:
std::vector<byte> v(4) = "...
Hey,
I'm working on event handling in C++ and to handle notification of events, I have a class EventGenerator which any class generating events can inherit from. EventGenerator has a method which other classes can use to add in callbacks and a method to call the callbacks once an event happens
To handle notification of different types ...
SetUnhandledExceptionFilter() lets me install a function that gets called in case of an unhandled exception. I'm looking for a way to get the currently installed function, so I can store&restore it. I can't seem to find a Get equivalent of the SetUnhandledExceptionFilter call, and am wondering if I'm missing something or if it's just...
I'm wondering how to convert a hex string to a human readable string (if that makes any sense) this would be my first real encounter with hex values so I'm still learning about them and how to manage them.
I have a program which is reading in data from a file which contains raw packet data (hex) and I need to parse this information so i...
I got multiple versions of libc installed,
how do I choose which to link with at compile time?
Right now i'm compiling like
g++ prog.cpp
...
Here's a question more for you old school Windows C++ developers.
I'm trying to connect to an Exchange 2003 server using RPC over HTTP with SSL using ncacn_http but I can't seem to get the right parameters when configuring the binding. I have been able connect to the server locally using ncacn_ip_tcp just fine. I currently have Outloo...
I'm trying to use va_arg to make a generic factory function in my GUI library.
When passing va_arg twice in the same function they pass on the same value instead of two different:
GUIObject* factory(enumGUIType type, GUIObject* parent, ...){
va_list vl;
va_start(vl, parent);
...
label->SetPosition(va_arg(vl, int), va_arg(vl,...
I have a class 'Vector3' which is compiled successfully. It contains both non-friend and friend functions, for example, to overload * and << operators when Vector3 is the second operand. The problem is I can't link to any of the friend functions, be it operator overloaded or not. So I can confirm that the error is not specific to operato...