462 Posted Topics
Re: You lost me but.. If the class is declared in a different file, you must include that header file in your main by doing #include "HeaderFile.hpp" or whatever extension you saved it as. If it is declared in main like so then you just create an instance of that class … | |
http://i.imgur.com/kWrBizl.png In the above Image, I generator a Sudoku Matrix of 9x9 values. Is there any way I can allow user to enter individual values by moving around the caret and typing? Basically, I want them to just be able to change the values displayed on the screen by moving … | |
Re: I also started cross-platform coding a while ago.. Maybe two-three months ago. I use Windows 8 Pro and installed Linux on Hyper-V. Remote Desktop into the Hyper-V machine and set it to full screen :) Can copy paste my code/folders/project from Windows to Linux and just press compile. Vice-Versa works … | |
Re: How about using Templates? Or using the Object data type since it's polymorphic anyway? public void Print(...array<Object^> ^objects) { foreach (Object^ o in objects) Console::Write(o + " "); } Object Datatype can accept any other type whether it is known or not.. For example, a class. Of course for the … | |
How can I calculate CLOCKS_PER_SEC.. It is defined as 1000 in ctime. I don't want it defined. I want to calculate the actual value.. I tried the below code but it seems to be giving me my CPU speed.. on a 2.8 Ghz processor, it prints 2800. On a 2.0 … | |
Can C++11's Mutexes be used for Inter-Process Communication? In other words, can it be used for shared memory and signalling an event? Currently, I'm using CreateEvent and SetEvent from WINAPI and I wanted a cross-platform way of doing so without doing #ifdef windows and ifdef linux, etc.. I use CreateEvent … | |
Re: I'm going to have to go with GCC on this. The only thing I saw new that I really wanted from MSVC 2012 was that it had the std::filestream which I really really!!! liked. GCC has more important/useful features IMO. But MSVC is getting there. Just get both. I don't … | |
Re: His code compiles fine. I don't know why Netbeans gives you compile time errors. Alternatively, you can try what I use.. Should be fairly similar: void ClickMouse(HWND Handle, int X, int Y, bool ClickLeft) { UINT UP = ClickLeft ? WM_LBUTTONUP : WM_RBUTTONUP; UINT DOWN = ClickLeft ? WM_LBUTTONDOWN : … | |
I'm diving into various Image reading and writing methods and writing my own. I decided to tackle TGA/Targa. I got reading working flawlessly. It reads both compressed and decompressed .TGA files. I got writing decompressed .TGA files working. However, I cannot figure out how to write Compressed .TGA files. I … | |
Why can't I capture the variable Painted and change it? The second that I capture it, it throws a compile time error: > *cannot convert 'Foo()::<lambda(HWND, uint32_t, WPARAM, LPARAM)>' > > to > > 'WNDPROC {aka long long int (*)(HWND__*, unsigned int, long long unsigned int, long long int)}' in … | |
Why can't I capture the variable Painted and change it? The second that I capture it, it throws a compile time error: > *cannot convert 'Foo()::<lambda(HWND, uint32_t, WPARAM, LPARAM)>' > > to > > 'WNDPROC {aka long long int (*)(HWND__*, unsigned int, long long unsigned int, long long int)}' in … | |
This may be a long post but I really need to know how to Convert between the two image formats and amonst themselves as well. Here goes: I have a struct like the one below that holds all pixel information: typedef union RGB { uint32_t Color; struct { unsigned char … | |
I'm in a bit of a dilemma. I want to know what the difference is between Foo and Meh. I wrote both of them and I did not like Foo so I wrote Meh. They both work but is there an overhead to Meh? Is there anything bad about Meh? … | |
Re: Try exporting with /MT enabled. | |
Re: #include <iostream> #include <fstream> int FileSize(std::string Path) { std::ifstream Stream(Path.c_str()); if (Stream.is_open()) { int Start = Stream.tellg(); Stream.seekg(0, std::ios::end); int End = Stream.tellg(); Stream.close(); return (End - Begin); } return -1; } int main() { std::cout<<FileSize("C:/Users/Foo/Desktop/SomeFile.bin")<<std::endl; } | |
Ok I know the difference between delete and delete[] BUT this question just all of a sudden popped in my head since "NOTHING" happens when I use delete[] for all purposes. Now I know when to use one or the other but it still for some odd reason bothers me … | |
Re: Your GetInfo doesn't return a value everywhere. Actually, it only returns a value within that while loop. Lets assume that the while loop "never" executes and it skips over it.. What happens then? What did you return? Also perhaps it crashes because you never closed any of the streams you … | |
Re: Can I suggest that you should use a switch-case statement as well? switch(key_stroke) { case 13: //Add key to the log. break; case VK_TAB: //Add key to the log. break; case VK_SHIFT: //Add key to the log. break; //etc... default: //Unknown Key was pressed.. break; } | |
I'm trying to flip an image which has its pixels stored in a vector. For some reason, when I try to flip it, the image gets distorted and gray/fuzzy. Any idea why? My code is as follows: void JNIData::FlipBytes(void*& Result, bool TopDown) { unsigned char* Pixels = &BufferPixels[0]; //vector of … | |
Re: Line 30.. Every time the loop calculates, it calculates using your CharHealth which is still at 100! float remhealth=charhealth-enemyattack; charhealth = remhealth; //Next time the loop starts, it will start with your current remaining health. I "THINK" that's what you want. It's a bit difficult to understand your question but … | |
I have a void pointer that I casted to a char*. I'm trying to put different data types in that char* without having to cast so much. This includes doubles, floats, int's, etc.. char* Data = static_cast<char*>(GivenPtr); switch(reinterpret_cast<int>(Data)[0]) //Or should it be reinterpret_cast<int>(Data[0]) { case OBJECT: //defined as 301; { … | |
Does anyone have a tutorial for writing Custom Allocators and Memory Pools for std::vectors and Objects? Basically I've looked at placement new and I want to know how I can force vectors to use this with my shared memory pointers. I'm thinking writing a class for it might be much … | |
Re: GDI and GDI+ has the ability to draw a variety of things. | |
Re: Well for one, you are asking the loop to stop ONLY if the user enters 6. Perhaps you want it to break out when an option is chosen? Also have you considered using a switch case statement? Another thing is that if you want it to break out of the … | |
![]() | Re: Well I wrote a class on this a while back. GetPixel was significantly slower for me. It will be faster than using GetPixel since you already have a list of all colours. It's like a bitblt vs. setpixel 5000 times. I'll PM you a part of the class. ![]() |
Re: Why not use: http://www.freepascal.org/docs-html/rtl/system/move.html | |
Re: There is nothing wrong with your Vector.. It's the for-loop logic. `for(counter = 0; counter < sOList.size(); counter++)` when that for-loop ends, counter will have retained its value from the last iteration. you need: `for(unsigned int counter = 0; counter < sOList.size(); counter++)` That way, counter starts at 0 all … | |
Re: The only problem I spotted after a very very quick look at your code was that you never incremented "Counter" in your Input function. Thus you were stuck in an infinite loop. I haven't tested this but meh.. Since I see you already posted and shown an attempt, I'll show … | |
Re: You are checing whether the mouse is moving or not? Thus you need to do something like (PSuedo code): int X = 0, Y = 0; int X2 = 0, Y2 = 0; bool MouseDrag = false; if (MOUSE_LEFTButton == DOWN) { GetMousePos(&X, &Y); MouseDrag = true; } if ((MOUSE_LEFTButton … | |
Re: Uh we don't do homework without you showing effort. In fact, we don't do homework at all but I'd definitely be gladd to help or show you how if you can show me that you tried something or understand pointers/arrays. | |
Re: char is just like any other Data type. You can do: char VariableB = 'B'; char K = 'K'; char Zero = '0'; char NULLS = '\0'; //A char is always 1 character in length. An array of chars is called a string: char Str[] = {'T', 'R', 'I', 'U', … | |
Re: Uhh you're calling the constructor before getting user input. The question wants you to get user input first THEN use that input to construct the object. Thus get the user input, pass those values to the constructor. Also you might have had faster answers if you also posted the .cpp … | |
I had absolutely no clue where to post this but I figured since it crashes on the C++ side, I'd ask here. I have the following code: Java side (Loads My C++ DLL just fine.. Passes it a ByteBuffer so that I can write to that): import java.io.IOException; import java.awt.*; … | |
Re: Well I found that difficult to read.. You should really really format the code properly before posting it. I know it only takes two clicks to format it A-style but meh. If you did so, more people would take the time to read it. Also I'm not sure how you … | |
Re: Looks correct. It does indeed work. Make a file on your desktop called Foo.txt. Put the value 10 in it. Run your program and type exactly this: `C:/Users/Username/Desktop/Foo.txt` Replace Username with your username.. It'll print 10. Also note that the method you're currently reading with will break as soon as … | |
How can I figure out where words intersect in the following? AAAA#BBBB .#.##C##H .#.##D##I .#...E.#J ##.##F##K ###..G..L '#' represents the black spots in a crossword where you cannot fill in. '.' represents the spots with missing letters that need to be filled in. I've read the puzzle into a vector<string> … | |
Re: Stack unwinds. When you do a recursive call, it keeps pushing onto the stack. Then you have your return if it's less than 0. At that point, it basically breaks out and starts unwinding and printing every a value that was entered. Well at least that's the way I was … | |
Re: Question for you.. Are you sure the following is correct? if( lRet != ERROR_SUCCESS ) { if( lRet == ERROR_FILE_NOT_FOUND ) { bRet = FALSE ; break ; } else { bRet = FALSE ; //Are you sure? :S break ; } } The reason I'm asking is because it's … | |
Re: We cannot help if we do not know what your function looks like :S I don't see any for-loops. I cannot tell from just reading that what the problem is. Perhaps you are accessing an invalid section in memory when trying to read/store the array? That could be the cause … | |
Re: It's automatic as far as I can remember. It's been a while since I did inheritance/poly but when a derived class has a function with the same name as the base class, the derived class's member function is said to override the base class's. Well I think so at least. … | |
Re: Why not use the image as a resource? I believe most projects for most compilers search within the project's folder so that should be a good place for the image; correct? I'd still say use the image as a resource or if you're still stubborn enough, place it in the … | |
What am I doing wrong? In the following templated functions, I'm trying to convert all my CopyMemory functions to std::copy functions. I'm not sure what I'm doing wrong as they don't work as they should with the std::copy but instead, they work with memcpy and CopyMemory. I'm only doing it … | |
Why is C++ on linux basically C? I've tried everything to avoid C on linux but it's simply near impossible. I've tried to stick directly to the standard library but I somehow find myself using dirent.h, types.h, etc.. Is there any other ways to do these other than using C … | |
Re: #include <windows.h> #include <iostream> #include <ctime> #include <cstdlib> using namespace std; int Die_1 = 0, Die_2 = 0; void RollDice() { Die_1 = (rand() % 6 ) + 1; Die_2 = (rand() % 6 ) + 1; } int ComputerRolls() { RollDice(); return (Die_1 + Die_2); } int UserRolls() { … | |
I'm learning several languages. 5 at once but I took a liking to one specific feature of java. The This keyword. From their tutorial: /*Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called. You … | |
Is there a way to do the following better? Current I write a set of pixels to a file called "PngFile.bmp". Then I read that file back in as a PNG encoded buffer.. Then I save that buffer back to the harddisk and delete "PngFile.bmp" /*std::fstream PngFile(TempPath, std::fstream::out | std::fstream::app … | |
So I've started learning makefiles today for a project I've been working on. The project uses OpenGL and GDI. I decided to dive right into make files and so far, everything compiles but at the very end, it gives a bunch of undefined references. Thing is, when compiled in codeblocks, … | |
Re: Not sure why the above suggestions were sprintf :S string VariableString = "gsdgdsghas"; string FilePath = "test/" + VariableString + ".txt"; ofstream write(FilePath.c_str()); | |
Re: Maybe `file_map[prefix];` doesn't exist or points to an invalid memory location? Also are you sure you don't have to do: `file_map[prefix].ofs.close()`.. Then delete? | |
I've been trying to do this for some time. I can do it with a vector but with a const void*, it crashes badly! My bad code: Bitmaps::Bitmaps(const void* Pointer, int Width, int Height, uint32_t BitsPerPixel) { Pixels.clear(); memset(&Info, 0, sizeof(BITMAPINFO)); width = Width; height = Height; size = ((width … |
The End.