I'm in my first class for C++. Can someone please tell me how to declare a string "consumer"?
Thanks in advance
I'm in my first class for C++. Can someone please tell me how to declare a string "consumer"?
Thanks in advance
Or since this is a class and you probably aren't supposed to use the string class:Code:#include <string> std::string consumer;
100 is an arbitrary size, change it to suit your needs.Code:char consumer[100];
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
If I were to have #include main() can I also have #include <string> in the same code?
Thanks for your response.
you're not supposed to #include main().
anyways, yes, you can include more than one header file, and if your program calls for more then one, than you should.
I'm confused! Can you please explain to me why I'm not supposed to use #include main()? Because, this is what my professor is teaching us.
Your professor is an ignoramus (yes, you can tell him I said that). My advice would be to quit school, buy some good C++ books, and teach yourself!
Anyway, you #include files, not functions - perhaps he meant "main.h" (assuming the file exists in your program workspace)?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
#include main() won't even compile, I don't know how you can be taught such abominations anyway. If it is your first class, I won't be a good teacher, so, I'll just let others explain why it is so.
But this post will be aimless if I didn't do something for you, so, here is a basic explanation.
For now, you don't need to know what int main() is, all you have to keep in mind is that everything inside of the brackets is your code and will be executed.Code:// Consider a simple program that does nothing. // Here's the code. int main() { return 0; }
See? there's no #include main() thing. #include is designed to include a file into the one which use the directive. For instance, if your file, named "main.cpp" uses #include <stdio.h>, the file named "stdio.h" will be copied into the "main.cpp" when it is loaded into memory to be compiled.
The content of the file is not of import to you right now, just understand that it is here for you to use functions and classes (don't worry if you don't know what it is at present) that weren't available otherwise.
OMG..I'm sorry guys! I'm the ignoramus! lol..
Lack of sleep is a mofo. LMAO
I hope my post here isn't a reflection of what my grade is going to be in this class.
#include <iostream.h>
#include <string>
int main()
Jeez I'm a goof! Ok so a revised question here.. You can use as many #include as you see fit..correct?
Yes
Umm... Not realy... Header files are there for a purpose. Such as std, a standered namespace, won't work without iostream. Putting to many will just increase file size and make you look noobish...Originally posted by Newbie Magic
Yes
>Umm... Not realy...
Why? If you need 10 functions from 10 different headers, you have little choice but to include all of those headers. Not doing so would give unpredictable behavior and make you look noobish.
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
Oh, I thought he ment just put them there for like no reason, my badOriginally posted by twm
>Umm... Not realy...
Why? If you need 10 functions from 10 different headers, you have little choice but to include all of those headers. Not doing so would give unpredictable behavior and make you look noobish.
If your professor is honestly teaching to #include <iostream.h>, you should drop the class. That hasn't been legal C++ code for 5 years now.Originally posted by §tudent
OMG..I'm sorry guys! I'm the ignoramus! lol..
Lack of sleep is a mofo. LMAO
I hope my post here isn't a reflection of what my grade is going to be in this class.
#include <iostream.h>
#include <string>
int main()
Jeez I'm a goof! Ok so a revised question here.. You can use as many #include as you see fit..correct?
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
I still use .h.
Only because when I use
It says there is no namespace std.Code:using namespace std;
O_o
get a newer compiler.Originally posted by KneeLess
I still use .h.
Only because when I use
It says there is no namespace std.Code:using namespace std;
O_o