70 Discussion / Question Topics
Remove Filter Hey, I'm a C++ programmer, but I'm beginning to learn Java, and from what I see so far the two languages are very similar. The main difference I hear is that C++ has pointers and Java doesn't, but from my understanding Java does have pointers in a sense, the user … | |
Hey, Right now I'm using XP, and I was thinking of getting a laptop. Now, I've heard a lot of bad stuff about Vista, but most of the things I heard are "It sucks." Or "don't get it" or "it's extremely slow". Now, except for the last one those are … | |
I've been trying to code a catch me game (for anyone who doesn't know: a game with a ball that randomly jumps around the screen - the goal is to click the ball before it moves, and not to miss it). I've got the clicks part down. You can click … | |
On a laptop running Windows XP, I can't seem to view webpages or actually connect to any server. Going to pages in IE or firefox give me unable to connect/cannot display errors. Trying to ftp to a server through windows explorer or filezilla gives me simmilar errors. Everything I do … | |
Hey, I download DarkGDK for Visual C++ 2008 Express (also downloading the correct version of the Direct X SDK). I just saved the SDK in some random directory, so when I try to execute the test code, i get an error telling me d3dx9.h can't be found. So, where do … | |
I have a child of std::exception defined as: [CODE=c++] struct image_load_failed : public std::exception { image_load_failed(std::string const s) : message(s) {} virtual ~image_load_failed() throw() {} const char* what() const throw() { return "image load failed";//message.c_str(); } std::string const message; }; [/CODE] (I would normally have what() return message.c_str(), but I've … | |
I'm trying to load a bitmap into an Image object using the following code: [CODE=Java] System.out.println("Point A"); System.out.println("Point B"); m_image = Toolkit.getDefaultToolkit().getImage(getClass().getResource(filename)); System.out.println("Point C"); MediaTracker mt = new MediaTracker(null); System.out.println("Point D"); mt.addImage(m_image, 0); System.out.println("Point E"); try { System.out.println("Point F"); mt.waitForID(0); System.out.println("Point G"); } catch (InterruptedException ie) { System.err.println(ie); System.exit(1); } … | |
Does anyone actually use the .hpp file extension for C++ header files? I've never seen it used, but I was just working with geany, and I noticed that it only syntax highlights C++ specific things if the file extension is .hpp (or .cpp, obviously, but not .h). So what's the … | |
Hey, I just recently ran into a problem compiling a C++ project (no, I didnt mean to put this in the C++ forum). I got an error saying that a certain header file couldn't be opened (I had compiled with the same file before). I looked up the error and … | |
I'm trying to upload .js files onto my sever. This is the code: [CODE]<html> <head> <title>Add Ubiquity Command</title> </head> <body> <form action="add_ubiquity_cmd.php" method="post" enctype="multipart/form-data"> Name: <input type="text" name="name" /><br /> Description: <textarea rows="8" cols="30" name="description"></textarea><br /> JS File: <input type="file" name="file"><br /> <input type="submit" value="Add Command" /><br/> </form> <?php if(isset($_POST["name"])) … | |
Does mysql_real_escape_string() escape HTML character entities? I want people on my comment board to be able to post quotes in their comments, but they get escaped as raw ascii, so I run them through htmlentities() first, but it doesn't help. I only get it to work when I remove mysql_real_escape_string(), … | |
Hey, Are any of the brands of memory considerably better than any of the others? Should I worry about that, or should I worry more about the actual memory I'm getting. thanks. | |
Hey, I'm a first-time builder, and I just have some questions about what components to get. 1. How many watts do I need for my power supply? I know there are calculators for that online, but I'd rather get a rough estimate from a human. I'm getting an Intel Core … | |
Hey. I've never worked in industry, and I was just curious as to how exactly things work in the real world (as a C++ programmer). To be a bit more specific, what kind of things do you do in a day? If you're working on a program, how many people … | |
Hey I'm writing a color class, and I want to have a constructor that can take in an unsigned int like 0x00FF00FF and interpret it as fully opaque green. I have code for that (I think it should work, could someone check it?): [CODE] rzb::color::color(unsigned int hex) { m_red = … | |
Hey. I'm planning on buying a desktop, but I'm a little confused as to the difference between 32-bit Vista and 64-bit Vista, and exactly what those differences entail. Now, I think the technical difference is the size of the memory bus. Well, if I'm right, I'm not exactly sure what … | |
Hey, I've been trying to create an RPG, and I really have trouble moving with it. I really can't find any decent tutorials (or even books). The only book I've heard of (Making RPGs with DirectX, or something, by Jim Adams) got pretty bad reviews. The part I can't really … | |
Hey, I'm learning Objective-C, and they use [ICODE]#import "File.h"[/ICODE] instead of [ICODE]#include "File.h"[/ICODE]. The tutorial I'm using says that import is like an include once thing, and it basically implements the #ifndef blocks that's normally done manually in C++. I was just wondering if this is something specific to Objective … | |
I'm writing a program for a contest (it's a demo, not the actual thing - so I'm not cheating by asking for help - and my question isn't directly related to the algorithm they want anyway). To submit a program, you send them the .cpp file, and they execute it … | |
I'm having problems creating an array with a dynamic size using new. Here is the relevant code: [CODE] enum LandCondition { Bad, Good }; //... int IMG_WIDTH, IMG_HEIGHT; LandCondition* land; //... land = new LandCondition[IMG_WIDTH][IMG_HEIGHT];//causes errors [/CODE] The errors VC++ gives me are: error C2540: non-constant expression as array bound … | |
To my understanding, certain classes, like ifstream, have a conversion to a primitive data type, like bool. In other words, you can do this: [CODE] if((fin >> x) && done == false) //... [/CODE] Now, does this simply work because ifstream has the && operator overloaded, or can objects of … | |
Say I have a file file1.h: [CODE] namespace a { int Func() { return 5; } } [/CODE] and a file file2.h [CODE] #include "file1.h" namespace a { class Foo { Foo(); }; } [/CODE] and file2.cpp: [CODE] #include "file2.h" a::Foo::Foo() { Func();//<---- } [/CODE] Can Func() be referenced like … | |
In regard to good style, is it better to use the NULL macro, or should you just use 0? And should you cast either one to the type of pointer you're using? i.e.: [CODE] int* pInt = (int*)0;//this, int* pInt2 = 0;//this, int* pInt3 = (int*)NULL;//this, int* pInt4 = NULL;//or … | |
A friend of mine recently asked me how one would convert a .bmp font to a .ttf. I said I was unsure, but it got me thinking to how I would code a program to do that. How would someone who wants to create a .bmp to .ttf converter go … | |
Is it bad to make a reference parameter optional by giving it a default value? Like here: [CODE]int Parse(std::string filename, std::string& error = (std::string)"");[/CODE] Here, the caller of the function may pass an optional std::string that will be filled with an error message if there is one. Is this considered … | |
Hey, I'm running into some issues with delete[]. I have these lines: [CODE] delete[] temp1; delete[] temp2; [/CODE] in a loop. temp1 and temp2 are pointers to std::strings. In the first iteration of the loop, temp1 and temp2 are both NULL pointers. The statements work fine. In the second iteration, … | |
Hey, I'm writing an XML parser in C++. Currently it works, but too much of what needs to be done is left up to the end user. I'm trying to figure out a way to have a clean, more encapsulated interface for the parser, but I can't seem to think … | |
What's the difference exactly between opening a file stream in the default text mode and opening it in binary mode? The cplusplus.com article on file i/o mentioned a few things, but I really didn't get the gist of it. Could someone explain it? Thanks. | |
When using >> to extract data from an istream, are spaces skipped over? I.e., if I extracted every character from: "Hello, my name is not World.", would the 5 spaces not be read by >>? If so, is this behavior omitted from istream::get()? Thanks. | |
Hey, I'm attempting to write an XML parser in C++, and I have some questions on some XML syntax. First: what is the rule for what goes between the end of the last attribute and the end of a tag? E.g.: is this ok:[ICODE]<tag attribute="value" >[/ICODE]? is this ok:[ICODE]<tag attribute="value">[/ICODE]? … | |
Does this code look right for centering an image on the screen (in this case a chess board): [CODE=C++] int Chess::Board::Center(int width,int height) { if(m_texture == NULL) return 0; D3DXVECTOR2 center; center.x = (float)width/2.0f; center.y = (float)height/2.0f; m_position.x = center.x - (m_texture->GetWidth())/2; m_position.y = center.y - (m_texture->GetHeight())/2; return 1; } … | |
Hey, I'm starting out Java development, and I want to know exactly what I need to download. I believe I need to download the JVM, but what else? And I know there are IDEs like NetBeans where you can just press a button to build and/or run the program, but … | |
Hey, I'm working on a chess game, and I'm creating two enumerations - for piece_color and piece_type. I'm wondering what the difference is (whether it's an actual difference in the way the program executes or a matter of good object-oriented practice) between having the enums be global or having them … | |
Hey, I'm trying to run a simple DirectX program, it loads a model and displays it. I run it once, and it works. I run it again, doesn't work. Didn't change any code. Just recompiled, and it doesn't work. I'm not sure if the issue is with my computer (which … | |
Hey, sorry if this is the wrong place for this, but... A while ago I was thinking of getting a new laptop. At first I was going to focus on battery life, but as time went by I saw myself caring less about that and more about a quality machine. … | |
Hey, sorry if this is in the wrong forum. My computer keeps crashing, causing it to restart, and I don't know why. Here's what I know: [LIST] [*]It's happened only on Windows XP [*]Its happened on one of my machines multiple times,and just started happening on my second [*]The crashes … | |
Hey, What will happen if you link to the same lib twice using #pragma? Will this cause an error, or if the lib is already being linked to, will the second #pragma be ignored? Thanks. | |
Ok, I'm writing a simple program with VC++ and DirectX. It's basically a working framework for 3D games, but all I need it to do right now is load a mesh and display it, and it is killing me. I've done this successfully before, I don't know why its not … | |
Hey, So, three questions: 1. What is a DLL and what is a .lib file? 2. (might have been answered w/ #1) What is the purpose of .lib/.dll files? 3. How do I create a .lib file with C++, and (again, may have been answered above) what exactly will this … | |
EDIT: Ahhh.. nvm, I found it: [ICODE]die("Error with database".);[/ICODE] should be [ICODE]die("Error with database.");[/ICODE] Might anyone know why the following php script produces [I]no[/I] results? I.e., when I ctrl+u in Firefox, a blank screen comes up. [CODE=php]<html> <head> <title>Create Base</title> </head> <body> <h1>Create Base</h1> <form action="bases.php" method="post"> <table> <tr><td>Name:</td><td><input type="text" … | |
Hey, im trying to use the mail() function, but its not working. This is the script: [CODE=php] <html> <head> </head> <body> <?php if(mail("coolgamer48@gmail.com","Test","Test","From:coolgamer48@gmail.com")) { echo "Success"; } else { echo "Failure"; } ?> </body> </html> [/CODE] I keep getting "Failure". Is there an issue with my syntax, or is it … | |
Hey, I'm doing a school project on how math and physics are used in video games, and I'm trying to find things that I could talk about. The main idea I have right now is how trig is used to calculate the changes in x and y values of an … | |
Hey, I'm having a problem with my RPG. I'm trying to get a player to move from one room to another. All the coordinates (and other properties) of all the objects inside a given room are contained inside a text file, and this includes the properties of an exit to … | |
Hey, when I run this code: [CODE=Cplusplus]else if(strcmp(buffer,"#itemSprite") == 0) { char* sprite_filename = ""; int trans_r; int trans_g; int trans_b; int width; int height; int numFrames; int numCols; int frameChangeDelay; fscanf(file,"%s",sprite_filename); fscanf(file,"%d",&trans_r); fscanf(file,"%d",&trans_g); fscanf(file,"%d",&trans_b); fscanf(file,"%d",&width); fscanf(file,"%d",&height); fscanf(file,"%d",&numFrames); fscanf(file,"%d",&numCols); fscanf(file,"%d",&frameChangeDelay); item->SetSprite(sprite_filename,D3DCOLOR_XRGB (trans_r,trans_g,trans_b),width,height,numFrames,numCols,frameChangeDelay); }[/CODE] I get an error on this line: … | |
hey, is this code: [CODE=C++]if(m_velocity.x == 0) return 0; return ToDegrees(atan(m_velocity.y/m_velocity.x));[/CODE] any more efficient than this code: [CODE] if(m_velocity.x == 0) return 0; else return ToDegrees(atan(m_velocity.y/m_velocity.x));[/CODE] I.e., are we saving any time by omitting the else statement? | |
Hey, so I'm making a Breakout game in C++ w/ DirectX, and I'm having some trouble thinking of the ball bouncing physics. The way I've made breakout games before was to have the ball only move at 45 degree angles. This was fairly simple. Just reverse the x or y … | |
Hey, so I have a file I use to store my own math functions called MyMath.h. I included MyMath.h in my main.cpp file and it worked fine. But then I tried including it to another file, and I get this error: Block.obj : error LNK2005: "int __cdecl Random(int,int,bool)" (?Random@@YAHHH_N@Z) already … | |
Hey, am I correct in assuming that when you declare a function virtual in a prototype, it is illegal to use the virtual keyword again when you define the function? | |
Hey, So, I'm trying to learn DirectSound, and imagine my delight to learn that DirectSound doesn't have any interface for loading wave files! So MSDN refers me to the DXUT.h file that can be used to load .wav files and even to take care of some DirectSound stuff for you. … | |
I keep getting D3DERR_INVALIDCALL from my CreateDevice() call. Here it is: [CODE]long dev_result = d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_window,D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp,&m_device);[/CODE] I think the problem is with m_window. Here's its creation: [CODE]if((m_window = CreateWindow("WindowClass",m_setup->name,g_deviceEnumeration->IsWindowed() ? WS_OVERLAPPED : WS_POPUP,0,0,800,600,NULL,NULL,m_setup->instance,NULL)) == NULL) { MessageBox(NULL,"Error creating the window","CreateWindow()",MB_OK | MB_ICONERROR); return; }[/CODE] It's really weird. I put breakpoints … |
The End.