Hello, I recently took up learning C++ in preparation for future game development (And sure do have plenty of time to learn since I don't attend school or have a job). I ran into something I'm not sure of that I am hoping somebody here could answer for me.
Does the # symbol in the header for "#include" stand as a sharp or a number? I assume sharp at the moment, but will revoke my thoughts until I get a correct answer.
Thanks,
Brian
it's a precompiled header or directive. tells the compiler to do something before compiling the code. in this case, including a file full of probably definitions
they're called preprocessor directives, here's a quality hyper link: http://www.cplusplus.com/doc/tutorial/preprocessor.html
I might be a little off, but I think what you are asking is if the symbols used in C++ (like #, *, ->, ect.) have any ties to what the symbols would mean if you were not using a programming langauge... I think.
The answer to that would be no. The '#' is just a non-alphanumeric symbol that happens to be used in pre-compiler directives. Some math symbols (+, -, ect) are common sense, adding by using the tilde would be confusing.
I think thats what you were asking... I'm not sure though...
Sounds right on target to me! ;)
I just never knew as to whether or not the symbol had any sort of name associated with it.
C++ is a great language to learn. I'm sure my time spent learning it will be well worth it. I know that Battle.net's population is slowly coming to an end, but I want to eventually write a bot for channel moderation.
Also, I have heard you can only use the cout function when using <iostream>. Is this true?
Yes it is true, read this it tells you some of the functions for each libary
http://www.cplusplus.com/reference/iostream/
Quote from: ChroniX on January 18, 2007, 03:34 PM
Also, I have heard you can only use the cout function when using <iostream>. Is this true?
cout isn't actually a function, it's an object.
Well Mynd, thank you very much for pointing that out. :P
Well I'm having a problem here and hopefully somebody can help me. I get this error when trying to compile the code below
error C2784: 'std::basic_istream<_Elem,_Traits> & (Location of project on drive)
#include <iostream>
using namespace std;
int main()
{
int number;
cout<<"Please enter a number: ";
cout>> number;
cin.ignore();
cout<<"You entered: "<< number <<"\n";
cin.get();
}
cout >> numer;
you can't get input from cout.
cin >> number;
Ah okay, that's it! Thank you very much for your help. :)
What is wrong with this code? It will compile but wont execute.
#include <iostream>
using namespace std;
void playgame();
void loadgame();
void playmultiplayer();
int main()
{
int input;
cout<<"1. Play game\n";
cout<<"2. Load game\n";
cout<<"3. Play multiplayer\n";
cout<<"4. Exit\n";
cout<<"Selection: ";
cin>> input;
switch ( input ) {
case 1:
playgame();
break;
case 2:
loadgame();
break;
case 3:
playmultiplayer();
break;
case 4:
cout<<"Thank you for playing!\n";
break;
default:
cout<<"Error, bad input, quitting\n";
break;
}
cin.get();
}
Why don't you use a little debugging (either with breakpoints in VS or simply by printing out the value of input)