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

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?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×