C++, default parameter with no default constructor
what does standard say about such case: template<class C> struct A { A(C c = C()); }; struct C { C(int); }; A<C> a(C(1)); btw, Comeau does not raise error. ...
what does standard say about such case: template<class C> struct A { A(C c = C()); }; struct C { C(int); }; A<C> a(C(1)); btw, Comeau does not raise error. ...
Hi, I'm trying to create a simple qDebug-like class I can use to output debug messages in debug mode, dependant on some debug level passed when calling the app. I liked the ease of use of the QDebug class (which could be used as a std::cerr and would disappear when compiling in release mode). I have this so far: #ifdef DEBUG static...
OWASP says: "C library functions such as strcpy (), strcat (), sprintf () and vsprintf () operate on null terminated strings and perform no bounds checking." sprintf writes formatted data to string int sprintf ( char * str, const char * format, ... ); Example: sprintf(str, "%s", message); // assume declaration and ...
Hi. I'm trying to write an application using ajax, with Nginx as frontend, proxying relevant requests to a little application I wrote. All it does is to epoll some sockets and use the file descriptors. Here are some code snippets : Nginx configuration : upstream cometutils { server unix:/tmp/cutil_socket; } ... location /test { pr...
I have this SphereInFrustrum function here: 0.49% int FrustumG::sphereInFrustum(Vec3 &p, float radius) { int result = INSIDE; float distance; 2.40% for(int i=0; i < 6; i++) { 7.94% distance = pl[i].distance(p); 12.21% if (distance < -radius) 0.67% return OUTSIDE; 3.67% else if (distance < ...
Hello, i'm using Eclipse 3.6 for C/C++ for Linux. I need to compile existing project with my own working makefile. This makefile works well from the command line, but when I imported my project into Eclipse and try to use Build, it doesn't work, seems that it try to use makefile automatically created by Eclipse. I unchecked the switch "G...
Im working in C++ and I have a #define VAL 0x00000400. when I set a variable equal to the define: int value = VAL; when I run through the debugger is shows the variable value = 1024. could someone explain how that turns into 1024? Maybe some links to memory address info, #define info, or something relevant. Thanks ...
I'm new to C++, and I have a question that should be easy, but it's making me crazy. I'm trying to set up a 2D array. The array is declared in Solver.h like so: protected: static const int gridSize = 9; int theGrid[gridSize][gridSize] int *boxes[gridSize][gridSize]; ... and I'm trying to initialize it in Solver::Solver() ...
I', using GL_FOG, but it really only fogs up my geometry, I would like a way for the fog to feel like it encumbers an area, not just fog up my geometry, sort of like a box of fog... Is there a way to do this? Or possibly another way to give a smooth draw distance transition? Thanks ...
class MyClass { public: ~MyClass() {} MyClass():x(0), y(0){} //default constructor MyClass(int X, int Y):x(X), y(Y){} //user-defined constructor MyClass(const MyClass& tempObj):x(tempObj.x), y(tempObj.y){} //copy constructor private: int x; int y; }; int main() { MyClass MyObj(MyClass(1, 2)); //User-defined constructor was cal...
Is there a way to make the msvc compiler as strict as gcc? MSVC lets me do some pretty crazy things that result in hundreds of errors when I compile in linux. Thanks ...
Hi, I want to create macros that will insert a parameter into a function call. For example, I have function Action() declared below. Action takes as it's inputs an enum for the state number and a formatted string with optional args for the string. I want to define macros so that instead of calling Action( ActionState1, "someText %d"...
Here is my issue. I'm rendering axis alligned cubes that are all the same size. I created an algorithm that rendered around the player like this: ****** ****** ***p** ****** ****** While this does work, the player does not see this whole radius. I know the player's rotation angle on the Y, so I was hoping to modify my algorithm based ...
Hi, I'm trying to understand how these languages work under the hood. Unfortunately I only ever read very superficial things. I'll summarize what I know already, I would be really happy if you could correct me, and most of all, help me enhance my little bits of half-knowledge. C++: The C++ compiler preprocesses all source files. This ...
I can find tonnes of article's about starting up an IOCP server, but none about properly shutting it down =/ What is the proper way to shut the server down when you are done? more specifically, I already use PostQueuedCompletionStatus() to tell the worker threads to quit, but don't I also need to cancel all the pending IO, and close all...
Hello, I have spent the last 8 months learning as much C++ programming as possible from all free internet sources I could find. Though I work part time at a crappy job, I have been putting in about 20-30 hours a week into learning programming, and now I am a bit uncertain about what I should learn next. What I know fairly well at this p...
In my program the user can switch between full-screen and windowed modes. The full-screen mode potentially changes the screen resolution, and switching to windowed mode changes it back to what it was previously. At the program's termination the operating system automatically restores the screen resolution to it's default if it detects t...
I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest? ...
How to claculate the sum or product of each row and column separately in a 2-d array. ...
Previous, I have the following code. double* a[100]; for (int i = 0; i < 100; i++) { // Initialize. a[i] = 0; } The purpose of initialize array of a to 0 is that, when I iterative delete element of a, everything will work fine still even there are no memory allocated still for element of a. for (int i = 0; i < 100; i++) { ...