I recently read a lot about "preventing heap allocation for a class" (see this question).
I was able to understand "how", but now I can't figure out "why" someone would like to do that.
I guess there must be legitimate reasons for this, but I just can't figure them out.
In short: "Why may I want to forbid users from creating objects o...
iam working on my own class for complex numbers which add,subtract,multiply,divide 2 complex numbers and besides this behavior it also get Trigonometric and hyperbolic functions for complex numbers
can you help me please in implementing this Trigonometric and hyperbolic functions
and this is my behaviors including sine function is this ...
Hi, i want to use string inside Union.
if i write as below
union U
{
int i;
float f;
string s;
};
Compiler gives error saying U::S has copy constructor.
I read some other post for alternate ways for solving this issue.
But i want to know why compiler doesn't allow this in the first place?
EDIT: @KennyTM: In any union, if...
I expect it should share a common description, like XmlSchema or IDL and should generate classes for target language.
I found Thrift and it's really nice solution, but it doesn't support structures polymorphism.
I would like to have collections of base class objects, where I could place instances of subclasses, serialize this and deseri...
I have two functions :
void foo(const char * p)
and
template<size_t T_Size>
void foo(const char (& p)[T_Size]) ;
Given the call:
int main(int argc, char* argv[])
{
char a[21] ; // typeid : A21_c
sprintf(a, "a[21] : Hello World") ;
const char * b = "b : Hello World" ; // typeid : PKc
// note ...
I've written a two short programs that use anonymous pipes to communicate. The parent process shares the pipe handles by setting the standard IO handles for the child:
// -- Set STARTUPINFO for the spawned process -------------------------
ZeroMemory(&m_ChildSI, sizeof(STARTUPINFO));
GetStartupInfo(&m_ChildSI);
m_ChildSI.dwFlags ...
Way 1:
HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL,
CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pGraph));
Way 2:
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
What's the difference, why ?
...
Does it makes sense to drag and drop QWidget to QGraphicsScene or does it have side effects?
...
Hi,
I'm experimenting with developing a tool for remote OpenGL rendering, in C++. The basic idea is:
The client issues OpenGL commands like it's a normal app
Those commands are actually sent over the network to an external server
The server performs the rendering using some off-screen technique
Once done, the server transmits a singl...
What are the other equivalent libraries of C++ Qt ?
If anybody has used please share your experience with this community.
If anybody knows altrenative please let us know yourr experience with these libraries
...
Hello,
I've have investigating the effect of __restricting certain pointers in a C++-code, when compiling it via the GCC-compiler.
It turned that not only the run-time remains quite the same, but the executable doesn't seem to have changed, the size in bytes is exactly the same as before.
My GCC-version is
gcc version 4.3.2 [gcc-4_3-...
I have a big application that uses the dynamically loaded libraries. At the end of program while terminating it either segfaults or spits a message "glibc detected corrupted double-linked list". Looking at the valgrind output I think this is what the case is:
let say we have three files:
utilities.c - compiled with -fPIC and used...
I can't find a good explanation about global non static variables in unnamed namespace. I avoid global variables as much as I can. In this particular case I'm interested about behaviour just from pure theoretic side.
Suppose the following code:
In a.h
namespace ai {
class Widget {
void DoSomething(int param);
};
}
In a.cc
n...
I'm running windows XP and Visual Studio 8 on a C++ project.
It's obvious from the performance profile of my program that there is a memory leak, and when I downloaded the trial version of Purify it confirmed that I have at least two leaks, although, irritatingly, it would not tell me where they are. However, neither Visual studio's bui...
I have been tasked with removing RogueWave components from a legacy C++ codebase. To do so, I am attempting to build wrappers around the existing components, make sure that the code functions the same, and then choose a different library like boost to stick into the wrappers.
One of the problems I am coming against is that much of the ...
Hey all!
I'm trying to write a function for a database class that is basically just a wrapper around a hash_map of objects (say shapes) indexed by ID numbers that will look up an ID and cast it to the appropriate pointer type.
e.g. I'd like to be able to do something like this:
Circle* shapeToLookup = NULL;
int idNum = 12;
database.lo...
A large amount of functionality is duplicated between standard c++ and Qt. At some point it seems logical but many times it looks foolish. Like I feel like doing a new programming language, learning things which I already know. e.g. using QFile.
Also if I do it all Qt way and suppose now I want to move out of Qt framework it will be too...
I'm sure I've seen this somewhere but can't remember where and it might have been in C# anyway.
I have a bunch of game-objects that get looped through each being updated. Is it possible to break an update method if its taking to long?
For instance if a programmer adds a bunch of code that takes to longer to do during 1 update cycle can...
Does anybody know of a function to convert the EXCEPTION_POINTERS structure returned from GetExceptionInformation() into a string that I can log?
I don't want to roll my own if it's already been done.
EDIT: Basically, I've added the __try{} __except(){} blocks to help the app fail gracefully on a critical error. While I'm at it, I'm t...
Google was nice enough to explain how to wrap C++ class methods with accessors that can be used from the V8 Javascript engine.
However, they don't mention how to determine the name of the JavaScript object that will have these accessor properties available.
How do I tell V8 Javascript what the name of the C++ class instance (from the s...