- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 3
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
40 Posted Topics
Re: [QUOTE=invisal;653516][B]Text-based Role-Playing Game Project [COLOR="Green"](For Beginners)[/COLOR][/B] [INDENT]Firstly, this game will start with an introductatory storyline of the game to attract player interest. Then, it asks a player to enter his or her name and which class the player want to choose. There are going to be 3 classes for player: … | |
Re: [QUOTE=twek;728917]title is self explanatory how do i convert it to a std::string? all this LP stuff makes my brain hurt...[/QUOTE] try static_cast<std::string>(the_LPWSTR_var); or if it doesn't work reinterpret_cast<std::string>(the_LPWSTR_var); | |
Re: You can do it your self if you know some math :) w o r d = 4 letters which aren't the same = 4! s h e e p = 5! / 2! (the 2 ee) | |
Re: Get a book. I started with [URL="http://www.amazon.com/Beginning-C-Game-Programming-Development/dp/1592002056"]Beginning C++ game programming[/URL]. It's a great book to begin with. | |
Re: [QUOTE=serkansendur;730786]is there any vay to access iterator's index value without using another variable in the for loop?[/QUOTE] [code=C++] #include <iostream> #include <vector> using namespace std; int main() { vector <int> vec; vector<int>::iterator iter; for(int i = 0; i < 5; ++i) vec.push_back(i); for(iter = vec.begin(); iter < vec.end(); ++iter) cout … | |
Re: You overload an operator when it makes sense to do so. Say that you create a custom string class [b]MyString[/b]. It makes sense to overload the [b]+[/b] operator, but not the ~. | |
Re: shoe_copy=shoe1; will call the assignment operator, not the copy constructor. The copy constructor is called for example when you pass an object to a function by value. // copy constructor called (notice I pass by value, not by reference) void f(Shoe s) { } | |
Re: You can do that: [code="C++"] bool checkUnsignedInt(const string &str) { return atoi(str.c_str()) >= 0; } [/code] | |
Re: You can't return two values from a functio using the return statement. Use a struct as you've been told to above: [code="C"] typedef struct { int x, y; } P; P getPoint() { int a, b; //a = .... b = ..... P temp; temp.x = a; temp.y = b; … | |
Well my main() function has become a mess... What should I do next time to prevent this? [code="C++"] int main(int argc, char *args[]) { srand((unsigned)time(0)); if(!init()) return 1; atexit(cleanup); // to cleanup the surfaces // load images background = loadImage("background.jpg"); message = loadImage("play_again.jpg"); youWinMessage = loadImage("you_win.jpg"); youLoseMessage = loadImage("you_lose.jpg"); start: … | |
Re: [QUOTE]What I am trying to do is change the cin >> varible; into something different so when I find it easier when I code.[/QUOTE] Why do this? Is [b]cin[/b] hard to remember? You need to get used it, you'll see it everywhere!! Think of it as "[b]c[/b]onsole [b]in[/b]put", this might … | |
Re: Try darkGDK, it's free and very easy to use. Google it. | |
[code=C++] #ifndef DARK_OBJECT_H #define DARK_OBJECT_H #include "DarkGDK.h" namespace DarkObject { class Object // abstract { public: Object(); virtual void x() = 0; protected: int imageID, spriteID; }; class Rect2D { public: Rect2D(int x, int y, int width, int height): x(x), y(y), width(width), height(height) {}; int GetX() const {return x;} int … | |
Re: Read this: [url]http://www.daniweb.com/forums/announcement8-3.html[/url] | |
Re: [code=C]#include <stdlib.h> /* needed for rand() function */ #include <time.h> /*needed to call srand() (explained below)*/ int main(void) { int r = 0; /* by calling this function, we seed the random number generator. If we don't seed it, we will get the same numbers every time we generate random … | |
Re: [code=C++] void increment(const Machine &aMachine, int amount = 1) { rackID = rackID - amount; } [/code] [B]1.[/B] You are passing aMachine as [B]constant[/B] reference and you are trying to change a member of aMachine. This is illegal, since it's constant. You could pass a reference: Machine &aMachine [B]2.[/B] void … | |
Re: [B]result[/B] is a local variable, which is destroyed when the functions ends. So a garbage value is destroyed. The best solution is to do what is said by the poster above. If you need to work with pointers you can do this: [code=C++] double* treble(double data) { double result = … | |
Hi, I'm studying operator overloading through [B]C++ the complete referece[/B] and I've got some questions. In the book, the author writes this: [code=C++] loc loc::operator++() { ++longitude; ++latitute; return *this; } [/code] This creates a new object and returns it. [B]1.[/B]Wouldn't it be more efficient to return a reference? [B]2.[/B]This … | |
Re: There are a couple of tutorials [URL="http://www.cprogramming.com/tutorial.html"]here[/URL]. | |
Re: Just a bit of advice. No one is going to download all these files. You should provide the code with the errors and try to explain. Help us to help you. | |
Re: Try adding header guards in header.h [code=C++] #ifndef HEADER_H #define HEADER_H #include <iostream> // put your includes in the header file so you don't need to include them in every file that uses this header #include <...> class blah_blah { }; ... #endif [/code] | |
[code=C++] int MAX_NUM = 600851475143; int max = 0; vector <int> ints; for(int i = 1; i <= MAX_NUM; ++i) if((int)MAX_NUM % i == 0) ints.push_back(i); cout << "size = " << ints.size(); [/code] I get 0. Something is wrong. I get 2 warnings: warning C4305: 'initializing' : truncation from … | |
Re: Why don't you write this program and see the results? | |
Re: Show some effort first and then people will help you. Don't expect others to do [B]your[/B] work. Just an idea: The class could contain a [B]static pointer[/B] that would point to the last element. You could set it in the constructor. | |
Re: [code=C++] int input; const int ANSWER = random_integer1 + random_integer2; do { cin >> input; // get input } while(input != ANSWER); /* this will repeat as long as input is not equal to the answer. when the correct value is entered, the loop won't run */ cout << "Well … | |
Re: You can have functions in Cargo that return the details and don't change any value. [code=C++] class Cargo { public: int get_weight() const {return weight;} // the const here means that this function cannot change anything from the class int get_height() const {return height;} int get_width() const {return width;} /* … | |
Re: [QUOTE=Ancient Dragon;737748]when using character arrays the == operator does not compare string content but string addresses, so it will never work. You need to call strcmp() which returns 0 if the two strings are exactly the same.[icode]if( strcmp(name[i], "Jack Danial" == 0) [/icode] . strcmp() is case sensitive, meaning "Jack" … | |
Hi. I made some headers I want to include in every project from the include directories. So I'll be able to do [I]#include <hello.h>[/I] instead of [I]"hello.h"[/I], and I won't need to place them in the same directory every time. So I did this: [IMG]http://i38.tinypic.com/2n1bdj8.jpg[/IMG] [IMG]http://i34.tinypic.com/33a4d1g.jpg[/IMG] but it doesn't work. … | |
Hi. I'm trying to overload +=, -= and *=. [code=C++] /*error C2297: '+=' : illegal, right operand has type 'Matrix *' error C2114: '+=' : pointer on left; needs integral value on right*/ Matrix* Matrix::operator +=(const Matrix *const m) { if(x == m->x && y == m->y) myArray::Add(ppMyArray, m->ppMyArray); return … | |
[code=C++"] int x[5]; x[4] = 10; *(x + 4) = 10; [/code] Array indexing has a cleaner syntax but (as I've read) pointer arithmetic is faster. My question is, is it worth to use pointer arithmetic? Is there a noticeable difference? |
The End.