Forum: C++ Aug 7th, 2009 |
| Replies: 7 Views: 349 |
Forum: C++ Aug 7th, 2009 |
| Replies: 7 Views: 349 You overload an operator when it makes sense to do so.
Say that you create a custom string class MyString.
It makes sense to overload the + operator, but not the ~. |
Forum: C++ Feb 8th, 2009 |
| Replies: 12 Views: 625 Call the copy constructor.
Let me explain:
Shoe shoe1; // calls the constructor
Shoe shoe_copy(shoe1); // copy constructor
Shoe shoe_copy = shoe1; // copy constructor, even if it seems it's... |
Forum: C++ Feb 8th, 2009 |
| Replies: 12 Views: 625 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... |
Forum: C++ Dec 7th, 2008 |
| Replies: 8 Views: 990 Try darkGDK, it's free and very easy to use. Google it. |
Forum: C++ Nov 25th, 2008 |
| Replies: 8 Views: 1,861 result 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... |
Forum: C++ Nov 17th, 2008 |
| Replies: 23 Views: 1,457 Do you have any book that you learn from?
edit:
the way you did it, it will ask only once for the answer and the program will terminate. In my version it will keep asking until you enter the... |
Forum: C++ Nov 17th, 2008 |
| Replies: 23 Views: 1,457 #include <iostream>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;
int main()
{
srand((unsigned)time(0));
int random_integer1 = 1 + rand() % 500; |
Forum: C++ Nov 17th, 2008 |
| Replies: 23 Views: 1,457 const int ANSWER = random_integer1 + random_integer2;
random_integer1 = (rand()%500)+1;
random_integer2 = (rand()%500)+1;
should be |
Forum: C++ Nov 17th, 2008 |
| Replies: 23 Views: 1,457 No problem. Post back if you don't get it working. |
Forum: C++ Nov 17th, 2008 |
| Replies: 23 Views: 1,457 replace these "
cin >> answer;
cout << "\n";
return 0;
} "
with that code. You will need to return 0 and close the brace of course :p |
Forum: C++ Nov 17th, 2008 |
| Replies: 23 Views: 1,457 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.... |
Forum: C++ Nov 17th, 2008 |
| Replies: 3 Views: 624 Don't forget to #include <cstring> to use strcmp() |
Forum: C++ Nov 7th, 2008 |
| Replies: 12 Views: 1,329 Is it an image you changed manually from .jpg (for example) to bmp by just renaming the file? |
Forum: C++ Nov 5th, 2008 |
| Replies: 8 Views: 4,101 try static_cast<std::string>(the_LPWSTR_var);
or if it doesn't work
reinterpret_cast<std::string>(the_LPWSTR_var); |
Forum: C++ Nov 5th, 2008 |
| Replies: 12 Views: 1,329 Ok.
optimizedImage = SDL_Display_Format(loadedImage);
should be
optimizedImage = SDL_DisplayFormat(loadedImage);
... |
Forum: C++ Nov 5th, 2008 |
| Replies: 12 Views: 1,329 Are you sure you added the library files from project settings? |