Jump to content
Sign in to follow this  
Archerzz

Need A Program Challenge

Recommended Posts

std::cout <<"Hello World\n";

 

right?

Just wondering, I just began learning C++.  dont bash me for being a n00b.

 

edit: so would this be a valid program?

#include <iostream>

using namespace std;

void didit()
{
    /*std::*/cout <<"I did it\n";
}

main ()
{
     /*std::*/cout <<"Hello World\n";
     didit();
}

508108[/snapback]

 

Un-needed scope operator errors fixed.

Share this post


Link to post
Share on other sites

those are unneeded? the book I use has a sentence that says to "just view std::cout as the output function and std::cin as the input command". I was under the impression that you do need it.

 

edit: do you think it is a good start?

Edited by martymcfly

Share this post


Link to post
Share on other sites
those are unneeded?  the book I use has a sentence that says to "just view std::cout as the output function and std::cin as the input command".  I was under the impression that you do need it.

 

edit:  do you think it is a good start?

508127[/snapback]

 

it aint needed because of the "using namespace std;" thing :) If you didn't have that, you'd have to do the whole std::cout blahness...

Share this post


Link to post
Share on other sites

what do u have the std infront of cout and cin for what does std mean / do?

Share this post


Link to post
Share on other sites

oh! KB added the using namespace thing. This is what happened:

 

KB reads code

notices no using namespace thing

adds

compiles

errors

says I dont need those thing

I did before it was edited

Edited by martymcfly

Share this post


Link to post
Share on other sites

so it does not really affect the code it just tells which library to use the command from?

Share this post


Link to post
Share on other sites
so it does not really affect the code it just tells which library to use the command from?

508148[/snapback]

 

Seems about it, yeah..

Share this post


Link to post
Share on other sites

Or, you could be a real man and open up the iostream header file, and then just copy and paste the cout... I want to say function, but it's part of the namespace, so I'm not sure...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...