miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 24 Jan 2012 03:44 PM |
| Hey, some people that know C++, can you show me a simple code that does something besides put words on screen? Because so far, all I've been seeing is cout. Can you show me something else? People say you can do anything with it...Well, all I'vee seen so far frothe wiki is just using cout -_- |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 03:48 PM |
Is it really that hard to google "C++ tutorials"?
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
1Ra
|
  |
| Joined: 02 May 2010 |
| Total Posts: 2400 |
|
|
| 24 Jan 2012 03:53 PM |
cplusplus.com
make a random number guessing game, use cin >>, and game loops. |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 24 Jan 2012 03:56 PM |
@1Ra
inb4ban
And yeah, I've been learning C++, and all I've seen (so far) is cout. But that doesn't really bother me. The more advanced concepts will be explained later in, but right now, we're stuck with cout. (I don't really see why it's so bad, though...)
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 03:58 PM |
Well obviously people always use print because to make visual effects requires multiple files... Ever noticed how the is always within one file? Assuming you are only looking at basic things, that is.
Like when I was learning Java, this is just about all that I saw with every tutorial:
System.out.println("Text");
But, when I started learning more advanced things, like imports, I learned how to make my own window with buttons and texts, layouts, make those buttons have events that fire when pressed, ect.
So basically, Wiki's mostly teach you the basic. They don't teach you how to make visual effects, unless you are on a wiki that only teaches that.
I don't know much about C++, so sorry if this is incorrect, but in Java, you have to import things that you want to use. Like Windows and buttons. I think the correct term in C++ is `#include`... But I am not really sure. So basically, you will have to look at all the libraries that you know of, and see all the things that they support.
TheNewScripter's ALT |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 24 Jan 2012 04:00 PM |
@DealerNextDoor
Yeah, I'm pretty sure you say both:
#include <iostream> using namespace std;
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
1Ra
|
  |
| Joined: 02 May 2010 |
| Total Posts: 2400 |
|
| |
|
|
| 24 Jan 2012 04:05 PM |
@1ra
I was banned for 7 days for posting a link to the Lua website :P
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 04:05 PM |
You don't have to use the `std` namespace; I believe there are others. I remember when I was trying to learn C++ about a year ago I forgot to use a namespace, but it had no errors.
TheNewScripter |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 24 Jan 2012 04:06 PM |
offsite link == maybe ban
if sorcus is in a bad mood
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 04:07 PM |
@swimguy
Oh yeah? I was banned for 3 days for telling someone they were racist. You tell me how that is logical at all.
P.S. The racist person didn't get any sort of consequence what so ever.
TheNewScripter |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 24 Jan 2012 04:10 PM |
@TNS
I know that. I was just pointing out that you use it whenever you use cout (or at least that's what I think happens).
But don't take my word and carve it into stone - the most advanced program I've written is this:
// This is my first C++ comment /* This is my first block comment */ #include <iostream> using namespace std; function main() { int a, b = 25, 5; int result = a/b; cout << result; return 0; }
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 04:12 PM |
No such thing as 'function' tag in C++... Let me correct it.
// This is my first C++ comment /* This is my first block comment */
#include <iostream> using namespace std;
int main() { int a, b = 25, 5; int result = a/b; cout << result; return 0; }
TheNewScripter |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 24 Jan 2012 04:13 PM |
I have the word int in my program, no worries. I was just trying to retype it from memory, and I mixed those up.
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 24 Jan 2012 04:17 PM |
Swimguy777
That's cause you a badboy :C |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 04:17 PM |
@TNS
Ok, this was my first ban ever. Someone asked for opinions about her drawings. I thought they were really good, but some people didn't. She decided to quit drawing, and I tried to convince her not to via PM. I got banned for 1 day for Adult Content. All I said was to not listen to them because she was a really good artist. Dunno how that works...
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
1Ra
|
  |
| Joined: 02 May 2010 |
| Total Posts: 2400 |
|
|
| 24 Jan 2012 04:17 PM |
the function tag is the type of value the function returns.
string derpherp(int herp) { int derp = herp*10 return derp; }
//compile error |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 24 Jan 2012 04:18 PM |
I downloaded the GC extension Google Dictionary specifically to check the definition of any word I might come across as unknown. Those C++ sites are confusing.
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 24 Jan 2012 04:23 PM |
@1Ra
Based off of your code, and having no previous knowledge of custom functions in C++, does this work?
string myFunction() { string myString = "I hate idiots."; return myString; }
Or do I have to call the function, include a library, what?
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 24 Jan 2012 04:30 PM |
"Because so far, all I've been seeing is cout. Can you show me something else?"
That's because it takes too much code to fit in a forum post to get the environment set up to display something like a window. When you want to show a windows there's actually a _lot_ of things that have to be specified and requested, you can't just tell windows "hey, make me a window", you need to tell it a lot of specifics.
And it would be quite difficult to understand even if the code were posted, because a lot of the concept you need to know to write windows code are not very intuitive ones at first.
What I can post is an example of using the "SFML" library to display a single window. C++ by default is _just_ a language with a very small amount of libraries for stuff like command line output, if you want to do something like use Windows you need to use a library for it, such as either the Native Windows libraries, which is quite difficult as I mentioned above, or using another library a person wrote. This is using the SFML library to make a window:
#include "SFML\Window.hpp" #include "SFML\Graphics.hpp"
int main() { //construct with a size and a window title sf::RenderWindow app(sf::WindowSettings(100, 100), "Hello, World!"); sf::Event evt; while (true) { //get all the events while (app.GetEvent(&evt)) { switch (evt.Type) { //if the user pressed the x button, close the app case sf::Event::Closed: app.Close(); break; } }
//color the screen red app.Clear(sf::Color(255, 0, 0)); app.Display(); } return 0; }
Non trivial to say the least. |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 04:32 PM |
@Stravant I've barely worked with C++ before. When the program starts, does it automatically call main()?
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 24 Jan 2012 04:35 PM |
main is the entry point, yes.
When you're working with a programming language like C++ code is not executed starting at the top of the code and running through it, because once the code has been compiled into an executable there is no "top" to start at anymore or direction to execute in.
Instead, code execution always starts with a call to a function of a certain name, which varies between languages but is often called "main". |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 04:36 PM |
@TheTopicOfBans i've gotten 2 bans for offsite links, both the end part of a youtube link and millions of warnings. I just got a warning yesterday for saying "grammar N4z1", not in 1337 though...
~I've been to nil and back. |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 04:37 PM |
Ah, it all makes more sense now!
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|