return value of NEW
it it possible that in some cases NEW returns some value, for example NULL, or it will always throw exception? thanks in advance ...
it it possible that in some cases NEW returns some value, for example NULL, or it will always throw exception? thanks in advance ...
I am trying to figure out how to extract the RGB value from the pixel chosen. Every time I click though, it gives me a value of 0, even though I am clicking on a colored triangle. void mouse(int button, int state, int x, int y) { if(state == GLUT_DOWN) { float mx = p2w_x(x); // pixel to world coordinates float my = p...
how to use threading on windows platform, do i need to include some lib or dll file, is there some command? ...
Is #define LBitmap std::list < CBITMAP *> a good practice? Edit: Alright, what can I do to convince my boss that this is bad practice? ...
I have a program that is highly multi-threaded and it contains an intrusive linked list of objects. I need to pass off the objects in this list to several threads, but only 1 thread will ever own the object at a time, meaning that I don't need this object or the pointer to it be shared. I wanted to create an intrusive list with a uniqu...
I'm learning about linear congruential generator in an algorithms and data structures course. After thinking about RNG implementation we've been using (a=429493445, c=907633385, mod=4294967296, X is _uint32), one thing came to my mind: Program has a function for setting seed. How important would that function be in C and C++? Here's ...
Hi all, Suppose I want to version the libs in binaries made. For static libs, I thought this approach would work but it does not: LibInfo.h - Base class for all libinfo classes. Registers an object in gvLibInfo vector when a child is constructed. #ifndef IFACE_H #define IFACE_H #include <vector> class LibInfo; extern std::ve...
In Direct3D, you can create any type of Vertex you like. You can have a simple Vertex with just positional information, or you could add colour info, texture info, etc etc. When creating your input layout, you define what parts of a Vertex you've implemented: D3D10_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B...
I have a tab-based application for windows, which I am developing by myself. I would like to add a subtle gradient to the background of my tab control. How would I go around doing this? What is the best method for me to use? I think that implementing a custom control that takes up the space of the tab control would work, but how would ...
Hi this is my generic class: template<class T, class PrnT> class PersonalVec { public: PersonalVec(); T &operator[](int index) const; const T &operator[](int index) const; private: std::vector<T> _vec; }; I'm required to implement 2 versions of [] operator: one that will return a const reference and a regular one t...
This is the statement from the C++03 standard, §14.7.1p5: If the overload resolution process can determine the correct function to call without instantiating a class template definition, it is unspecified whether that instantiation actually takes place. [Example: template <class T> struct S { operator int()...
hello everyone I'm trying to find this algorithm on c++ in net but can't, I found this one // Best solution function boolean hasLoop(Node startNode){ Node slowNode = Node fastNode1 = Node fastNode2 = startNode; while (slowNode && fastNode1 = fastNode2.next() && fastNode2 = fastNode1.next()){ if (slowNode == fastNode1 || slowNode...
I have a C++ application which makes extensively use of pointers to maintain quite complex data structures. The application performs mathematical simulations on huge data sets (which could take several GB of memory), and is compiled using Microsoft's Visual Studio 2010. I am now reworking an important part of the application. To reduc...
i m new to c.I want to FTP to a system and get the timezone of that system.in c++ ...
Hi, How can I view symbols in a .o file? nm does not work for me. I use g++/linux. ...
I have inherited a template to convert a string to a numerical value, and want to apply it to convert to boolean. I am not very experienced with the stringstream and locale classes. I do seem to be getting some odd behaviour, and I am wondering if someone could please explain it to me? template<typename T> T convertFromString( const ...
Does Visual Studio C++ Express 2010 work with unmanaged code? Or is it only managed? ...
The compiler is giving me the following complaints about the following class: class AguiWidgetBase { //variables AguiColor tintColor; AguiColor fontColor; //private methods void zeroMemory(); virtual void onPaint(); virtual void onTintColorChanged(AguiColor color); void (*onPaintCallback)(AguiRectangle cl...
I have a following templated struct: template<int Degree> struct CPowerOfTen { enum { Value = 10 * CPowerOfTen<Degree - 1>::Value }; }; template<> struct CPowerOfTen<0> { enum { Value = 1 }; }; which is to be used like this: const int NumberOfDecimalDigits = 5; const int MaxRepresentableValue = CPowerOfTen<NumberOfDecimalDigits>...
How to initialize a const char* and/or const std::string in C++ with a sequence of UTF-8 characters? I'm using a regular expression API that accepts UTF8 string as const char*. The initialization code should be platform independent. ...