byte array assigment
byte test[4]; memset(test,0x00,4); test[]={0xb4,0xaf,0x98,0x1a}; the above code is giving me an error expected primary-expression before ']' token. can anyone tell me whats wrong with this type of assignment? ...
byte test[4]; memset(test,0x00,4); test[]={0xb4,0xaf,0x98,0x1a}; the above code is giving me an error expected primary-expression before ']' token. can anyone tell me whats wrong with this type of assignment? ...
Hi, I have a class looking like this: #include <vector> #include "record.h" #include "sortcalls.h" template< typename T, template<typename , typename Allocator = std::allocator<T> > class Cont = std::vector> class Sort: public SortCall { This code is working and I'm calling it like this from other classes: Comparator c; // c...
It seems that my problem is a bug in MSVC. I'm using the Visual Studio 2008 with Service Pack 1, and my code works with GCC (as tested on codepad.org). Any official info on this bug? Any ideas how to work around it? Is the bug fixed in VS2010? All insights would be greatly appreciated. The code: struct Base { Base(int i = 0) : i(i...
In the unit test of a class, I try to declare a class variable by calling explicitly the empty constructor and pass it to a function that excepts a reference to the interface of the type I'm declaring, but the compiler produces error. When I just declare it without any explicit constructor call the function accepts it. See the code bel...
In other words something like pipe in windows ...
I'm in the process of writing a wrapper for some OpenGL functions. The goal is to wrap the context used by the game Neverwinter Nights, in order to apply post-processing shader effects. After learning OpenGL (this is my first attempt to use it) and much playing with DLLs and redirection, I have a somewhat working system. However, when ...
when copying arrays using std::copy is there a way to check to see if the copy went through correctly? especially if you have like hex values in an unsigned char array. I am not sure how one can verify that the copy went through and even if it did the values that were in one array copied over correctly. ...
Hi, there is any drawback in choose C++ and an object oriented model (classes) to implement a simulation in OpenGL (or DirectX)? It's preferred to use C and a procedural programming paradigm ? ...
Do they all inherit from a base class? Do I have to use templates? (I am referring to these http://www.codeguru.com/cpp/cpp/cpp_mfc/stl/article.php/c15319/) I am doing this right now: typedef std::mt19937 RNG; and then class Chooser { public: Chooser(RNG& rng, uint n, uint min_choices, uint max_choices): In other words, I'm ...
I have a BST which is a linked list in C++. How would I delete the whole thing from memory? Would it be done from a class function? ...
I am using the debug_new tool that come in the pack of tools NVWA made by Wu Yongwei. http://wyw.dcweb.cn/ I turned it off once to track a heisenbug, that now is fixed. But as I turned it on, my program throws a bizarre error: It loads, but before accepting any input it quits and writes on the console: "This application has requested ...
I have a structure containing character arrays with no any other member functions. I am doing assignment operation between two instances of these structures. If I'm not mistaken, it is doing shallow copy. Is shallow copy safe in this case? I've tried this in C++ and it worked but I would just like to confirm if this behavior is safe. ...
Recently I heard that memory in the stack is not shared with other thread and memory in the heap is shared with other threads. I normally do: HWND otherThreadHwnd; DWORD commandId; // initialize commandId and otherThreadHwnd struct MyData { int data1_; long data2_; void* chunk_; }; int abc() { MyData myData; // initialize ...
Quick question: In Qt (C++), how do I check if a given folder exists in the current directory? If it doesn't exist, how do I then create an empty folder? I couldn't seem to find any references online for it (or in qt's help) Thanks. ...
Hello, I've been trying to figure out how to drag and drop an image into a QGraphicsView using Qt and the QtCreator IDE. I have read the documentation here: http://doc.trolltech.com/4.6/qgraphicsscene.html#dragEnterEvent This documentation is too general for me to understand. Can anyone give me an example that works? I also found a ...
I have had really big problems understand the char* lately. Let's say I made a recursive function to revert a char* but depending on how I initialize it I get some access violations, and in my C++ primer I didn't find anything giving me the right path to understand so I am seeking your help. CASE 1 First case where I got access violatio...
I have code like this: class Base { public: void operator = (const Base& base_) { } }; class Child : public Base { public: }; void func() { const Base base; Child child; child = base; } My question is: since Child derives from Base (hence it should inherit Base's operator= ), how come when the statement child = base; ...
I have never compiled programs using CMake. I have downloaded the latest SVN of Allegro and tried compiling it multiple times, but no luck. I have looked allover the internet and have not found anything helpful. I have chosen to compile it for Visual Studio 9 2008. I don't really know where I have to link the source and the build. The Al...
I would like to know the rules specified by the C++ language standard for situations like: long x = 200; short y = static_cast<short>(x); Is y guaranteed to be 200, or does the standard leave this up to the implementation to decide? How well do various compilers adhere to the standard? ...
This error is inexplicably occurring. Here is the code and output: timer.cpp: #include "timer.h" #include "SDL.h" #include "SDL_timer.h" void cTimer::recordCurrentTime() { this->previous_t = this->current_t; this->current_t = SDL_GetTicks(); } timer.h: #include "SDL.h" #include "SDL_timer.h" class cTimer { private: ...