# 'sup with this???



## twyg (Sep 18, 2001)

Hey all,

This morning picked up Sams Teach yourself c++ in 21 days, signed up at ADC, downloaded the Dev Tools, and then it got wierd.

Made the file helloWorld.cpp, Project Builder loaded it all up nice nice, and then I typed in the code

int main()
{
    std::cout "Hello World\n";
    return  

The program crashed. Unexpected quit. 
So... why not go in vi. This time I finished the program, and everytime I attempt to open it in Project Builder, bam... 

I'm probably being stupid, but there is no harm in asking.
Also on that note  If I wanted to compile, and run my .cpp program in terminal how do I? 
Thanks in advance


----------



## Captain Code (Sep 19, 2001)

> _Originally posted by twyg _
> *Hey all,
> 
> This morning picked up Sams Teach yourself c++ in 21 days, signed up at ADC, downloaded the Dev Tools, and then it got wierd.
> ...



You want:
(put iostream in angle brackets.  I can't figure out how to make the forum display it if it's in angle brackets as it thinks it's HTML.)

#include iostream //contains definition for cout, endl etc.

int main(void)
{
    std::cout << "Hello World\n";
    return 0;
}

You have to include the code that defines cout before you use it by #include iostream(in angle brackets).  This should just generate a compiler error though.  You also should return an int (0 in this case tells the OS that the program is finished) because you specified int as the return type for main().


----------



## twyg (Sep 20, 2001)

Thanks, that worked out. I found also that when I completely wiped the Dev Tools from my machine, and reinstalled, I was able to actually type "return 0"

It was choking on the fact that it had to turn the 0 blue... 

I'm also going through all the docs on Dev Tools, and realizing that we're not working with C++ as much as we are with C, and on that note objective-C. 

Are there any books out (besides what apple provides) on objective-C?

later


----------



## Captain Code (Sep 20, 2001)

> _Originally posted by twyg _
> *Thanks, that worked out. I found also that when I completely wiped the Dev Tools from my machine, and reinstalled, I was able to actually type "return 0"
> 
> It was choking on the fact that it had to turn the 0 blue...
> ...



No problem.  Must've been a corrupted file or something in the Dev Tools.

Yes, you're right, it is Objective-C.  I actually have no experience with Objective-C as I'm a second year student in a Computer Programmer Analyst program, where we learn C++(for windoze, boo).  I know there are some books about programming Objective-C but I can't recall any of the names.


----------



## twyg (Sep 20, 2001)

Thanks for the help!  

--starts meandering off to Amazon.com--


----------



## Captain Code (Sep 20, 2001)

> _Originally posted by twyg _
> *Thanks, that worked out. I found also that when I completely wiped the Dev Tools from my machine, and reinstalled, I was able to actually type "return 0"
> 
> It was choking on the fact that it had to turn the 0 blue...
> ...



No problem.  Must've been a corrupted file or something in the Dev Tools.

Yes, you're right, it is Objective-C.  I actually have no experience with Objective-C as I'm a second year student in a Computer Programmer Analyst program, where we learn C++(for windoze, boo).  I know there are some books about programming Objective-C but I can't recall any of the names.


----------



## rhale1 (Sep 21, 2001)

I reccomend *NOT* getting the O'Riely Cocoa book. It is just a copy of Apple's ADC Docs. If you want a good book (so I hear), check out Big Nerd Ranch's Cocoa book, due out in November.


----------



## scruffy (Sep 21, 2001)

<i>I can't figure out how to make the forum display it if it's in angle brackets as it thinks it's HTML.</i>

Lemme try:

&lt; and &gt;

used the HTML codes &amp;lt; and &amp;gt;

Hmm.  I guess it worked.


----------



## Captain Code (Sep 21, 2001)

> _Originally posted by scruffy _
> *<i>I can't figure out how to make the forum display it if it's in angle brackets as it thinks it's HTML.</i>
> 
> Lemme try:
> ...



Thanks.


----------

