Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > want to learn c++

want to learn c++
Thread Tools
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Nov 27, 2001, 09:51 PM
 
i'm interested in teaching myself c++, or at least to begin teaching myself some basics to set me up for some programming courses in school.

what books would you recommend that function as good teaching tools for a beginner (i have lots of javascript/actionscript experience and knowledge of loop structures arrays and such...) and allow for more advanced topics.

i want something that teaches the logic as well as the syntax rather than just showing what to type.

thanks in advance for the suggestions,
amit
     
tie
Professional Poster
Join Date: Feb 2001
Status: Offline
Reply With Quote
Nov 27, 2001, 11:42 PM
 
Try the nutshell book.
The 4 o'clock train will be a bus.
It will depart at 20 minutes to 5.
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Nov 29, 2001, 04:37 AM
 
Originally posted by ameat:
<STRONG>i'm interested in teaching myself c++</STRONG>
Why? Java is much better, not just to use but also to teach you how it's supposed to be.
All words are lies. Including these ones.
     
Dedicated MacNNer
Join Date: Apr 2001
Location: World capital of drugs and prostitution. Hmmm... SEXTC...
Status: Offline
Reply With Quote
Nov 29, 2001, 05:18 AM
 
Originally posted by sadie:
<STRONG>

Why? Java is much better, not just to use but also to teach you how it's supposed to be.</STRONG>
Oh, there are many, many reasons to prefer C/C++ over Java. That's not to say that Java is useless -- as a language it indeed teaches you how you should write a program. If you don't know any languages yet, start off easy with JavaScript, Perl, then Java and C/C++.

And since you're on a Mac, why not take advantage of that and program in Cocoa? Stepwise has some very nice tutorials on Cocoa programming called the Vermont Recipes.
The one you love and the one who loves you are never the same person.
     
Mac Elite
Join Date: May 2001
Location: Earth
Status: Offline
Reply With Quote
Dec 1, 2001, 06:20 AM
 
You can get "Thinking in C++" or "Thinking in Java".
They are both very good books written by Bruce Eckel.
You can either download the pdf versions or buy them from
amazon.

Check http://www.bruceeckel.com

One last word:
Java is NOT better than C++. It's different
I do like C++ better than Java.
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Dec 1, 2001, 01:29 PM
 
I would sugggest learning C first. Not Objective-C, just plain old C.

The reason for this is that a great many programing languages were heavily incluenced by, if not outright descended from, C. Among these are, of course, Objective-C and C++, but also Java, JavaScript, Perl, PHP, and a host of others. By having plain C under your belt, you'll be better-equipped to learn these other languages, should you choose, because you will already know many of the basic concepts.

There are plenty of good books for learning C, so it's almost impossible to go wrong there. Once you have that, the C++ books mentioned in this thread are a good start for the basics.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Dec 2, 2001, 03:49 PM
 
This is the road I went:
-QBASIC
-Pascal
-MsBasic
-C
-Futurbasic (really a great little language and compiler)
-C ++
-Objective C
-Java

Alot of people will say learn a basic language first, but from what I found in learning C, one can get buy with almost no programming knowledge at all. I bought Codewarrior Version 5 Pro, and used the documentation that came with it to learn C, and the C++.

If you download Developer for OS X, from apple's developer website, they have some documents that can teach ya objective C. I don't know about everyone else, but I prefer Objective C over C++.

-----------------------------------------------------------------
A summary of all the books I read:
From Codewarrior:
-Learn C on the Macintosh (by Dave Mark)
-Learn C++ on the Macintosh (by Dave Mark)
-Learn Java on the Macintosh (by Barry Boone with Dave Mark)
From Apple
-Object-Oriented Programming and the Objective-C Language
-and a gazillion or so Documents, and sample code, and API refererces
-----------------------------------------------------------------

The easiest part is learning the C language, and C++ is pretty much the same thing, but with some more abstract ideas.

The hard part is learning Apple's API's (API's are code written by apple that let you do things like play sounds, and draw pictures onto the screen). I am still working on this, a project that started some time ago and is still causing me a lot of trouble. Even worse, with the release of OS X I had to and still am learning an entirely new set of API's.

-------------
This may seem like alot, but if you find that you really like programming, then it is worth it.

You can read the books alone, but it is pretty much useless to do so, because one tends to forget everything they learned unless they are actually programming. So you need a compiler. A compiler is the thing that converts your code into a program that your computer can run.

Instead of taking the road that I did, and buying a $500 compiler, you can now download the Apple Developer Tools for free, these are for OS X, so you will need to have that. If you bought OS X, it will have come with the Developer Tools on a CD, if OS X came with your computer, you will have to visit apples developer section. Here you will find links that tell you how to get started. To get Developer for OS X click on the link that says login to login to apple developer connection, on the page that appears, simple click join and enter in the appropriate information. When you login you can then search around in that little site until you find the download for Developr for OS 10.1. (You MUST HAVE OS 10.1 TO USE Developer 10.1, if you do not have this YOU MUST DOWNLOAD DEVELOPER FOR OS 10.1 ---- sorry for the caps, but it is important that you have the right version of developer for you OS version, and it is also a 200 mb download)

PS - I have said this before, but it annoys me that apple did not include developer on their new towers, even though they came with OS X!!!! I got dialup, and this download takes forever!!!

Anyways Good luck,
Tim
     
ameat  (op)
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Dec 2, 2001, 04:00 PM
 
thanks everyone for their replies.

i do have osx.1 as well as the developers tools. that is what set of my desire to learn. i fell in love with the new ability to use my local system to view html, php, and cgi without an external server and would like to take advantage of this system and start making little apps of my own rather than scour version tracker for something that's almost productive but not exactly what i need.

being that i have the opportunity, i'll probably enroll in a beginning com sci course at school and be taught the fundamentals in C. from there, it seems that i could probably then start to teach myself C++, objective C, or Java.

anyway, i greatly appreciate all of your suggestions,
amit
     
Junior Member
Join Date: Nov 2001
Status: Offline
Reply With Quote
Dec 3, 2001, 08:00 PM
 
This may sound like a dumb question, but can you take full advantage of Cocoa by programming in C++? Does the Apple dev tools that come with OS X provide a C++ compiler and the files necessary to let you program in Cocoa in C++?
iBook 600, 384MB RAM, 30GB HD
OS 10.1.4/9.2.2
     
Senior User
Join Date: Mar 2001
Location: Toronto, Ontario, Canada
Status: Offline
Reply With Quote
Dec 3, 2001, 09:44 PM
 
Ok, I just spent all day banging my head against the proverbial wall...

I managed to get the following books from the library today:

Learn C On The Macintosh
Learn C++ On The Macintosh
(Both by David Mark)

C++ For Dummies

I tried to run the following program in Project Builder:

---

#include &lt;stdio.h&gt;

int main (void)
{
printf ("Hello, world!\n";

return 0;
}

---

...and no matter what I tried, I couldn't get it done. So could someone *please* dumb it down 10 notches, feed me (or gag me) with the proverbial spoon, and show me how I run the examples in the Learn C book? If I can't even run such a simple example, how am I to learn how to program?

I ended up finding some Cocoa tutorials and built two simple apps from two seperate web sources that did a "Hello World" kind of thing. But it seems that without knowing what the classes are or how they work, it's pretty useless. Is there a book I should get for this?
     
Junior Member
Join Date: Nov 2001
Status: Offline
Reply With Quote
Dec 4, 2001, 12:57 AM
 
Well there's a parenthesis missing...

If you're asking how to write console apps in Apple's dev environment, I'd like to know myself...
iBook 600, 384MB RAM, 30GB HD
OS 10.1.4/9.2.2
     
Senior User
Join Date: Mar 2001
Location: Toronto, Ontario, Canada
Status: Offline
Reply With Quote
Dec 4, 2001, 07:46 AM
 
Originally posted by Skywalker:
<STRONG>Well there's a parenthesis missing...

If you're asking how to write console apps in Apple's dev environment, I'd like to know myself...</STRONG>
lol, thanks for pointing out the missing quote. I typed it in right in the program though

But yes, that's exactly what I'm looking for (I just didn't know how to phrase the question, which is a good 50% of the game) - how can I write console apps in Apple's dev environment???

Or barring that, how can I write console apps period? ie. what app could I use, whether freeware, shareware or commercial? Some maroons* I chatted with suggested using the Terminal somehow, but at the time, I wasn't too thrilled about the idea. But more and more, I'm getting to the point where I just want to say "F*** it, if I have to learn from the Terminal, then fine, just tell me HOW to do it d*mmit!"
     
Mac Enthusiast
Join Date: Jan 2001
Status: Offline
Reply With Quote
Dec 4, 2001, 12:41 PM
 
type your program like you would a regular text file.. in the terminal type
$pico program.c
type your program, save it then compile it with cc
$cc -o program program.c
     
Senior User
Join Date: Mar 2001
Location: Toronto, Ontario, Canada
Status: Offline
Reply With Quote
Dec 4, 2001, 01:25 PM
 
Originally posted by 00101001:
<STRONG>type your program like you would a regular text file.. in the terminal type
$pico program.c
type your program, save it then compile it with cc
$cc -o program program.c</STRONG>
Thanks for the tip! I tried as you suggested and it compiled!! It created a file named "program". Now for an even stupider question, how do I execute it? I tried typing "program" and it didn't work.
     
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Dec 4, 2001, 04:19 PM
 
Anyways, those C and C++ books by Davemark are designed to be used with a compiler called codewarrior. Codewarrior has all the libraries to use it, but Dev does not really have all of these... They are different compilers.

as far as launching that app from the console, try this graphical approach. Look in the folder that you compiled your app in, this should be your hope directory, and look for an app named program, and just drag it onto the terminal icon, and it should open...

or you can use the command line approach...

basic unix commands are:
ls-list contents of current directory

cd-change directory (ex. cd Applications/iMovie\ for\ Mac\ OS\ X will put you in your iMovie directory. Use "/" to tell the computer that you are starting the name of a sub directory, and use "\" to tell the computer that you are representing a space in the name of the directory. The above example, opens the folder "iMovie for Mac OS X" in the "Applications" directory)

exit-get out of terminal

use control-c to terminate (terminate is not a good thing as depending on the app, it may not shut down right) most apps, most will respond to a "q" or something similar

I don't know if you knew that, so sorry if you did know.

Anyways, to open your app using unix commands, you have to know where you compiled it to... probably your home directory. If this is the case just type "/Users/yourname/program\".

All directory paths are relative to the window that you get when you open your hardrive icon. Don't ask me how to acess other disks, though, cus I don't have 2 hard drives, and therefore have not needed to learn.

--
Correct me if I am wrong in any of the info presented
     
Grizzled Veteran
Join Date: Sep 2000
Location: Adelaide, Australia
Status: Offline
Reply With Quote
Dec 4, 2001, 09:06 PM
 
Originally posted by Kestral:
<STRONG>

Thanks for the tip! I tried as you suggested and it compiled!! It created a file named "program". Now for an even stupider question, how do I execute it? I tried typing "program" and it didn't work.</STRONG>
Type ./program


I think you have to do this because test
is not in your path. Your path is the list of all directories that
the operating system will look in to find the executable test.
Your home directory is not one of these by default because of
security concerns.


I you need to learn some UNIX have a look at the UNIX Introduction course notes (pf) at http://wks.uts.ohio-state.edu/


Michael
     
Forum Regular
Join Date: Oct 2001
Status: Offline
Reply With Quote
Dec 4, 2001, 11:21 PM
 
Kestral,
You should create a Standard Tool in Project Builder if you want to do console work. Create a new project and scroll down to Standard Tool. The other Tools also output to console, I believe, and the C++ Tool may be just what you want. An empty Project might also work if you want to have complete control.

kido
     
Senior User
Join Date: Mar 2001
Location: Toronto, Ontario, Canada
Status: Offline
Reply With Quote
Dec 4, 2001, 11:40 PM
 
Wow, thanks for all the great help everyone!! Managed to get it working. Not only can I compile/run using Terminal's CC command, but also figured it out in Project Builder!! This is great!! Looking forward to continuing with David Mark's C book (then I'll read his C++ one), while doing the examples!!
     
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Dec 5, 2001, 09:50 PM
 
They really are good books, it is how I was introduced to C and C++.

These books don't really tell one much about how to program things like an graphical interface. But now that OS X is out, that sort of stuff has been somewhat simplified. After you are done reading them, you should definetly check out apple's tutorials in their dev tools.
     
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status: Offline
Reply With Quote
Dec 10, 2001, 12:18 PM
 
Originally posted by ameat:
<STRONG>i'm interested in teaching myself c++, or at least to begin teaching myself some basics to set me up for some programming courses in school.

what books would you recommend that function as good teaching tools for a beginner (i have lots of javascript/actionscript experience and knowledge of loop structures arrays and such...) and allow for more advanced topics.

i want something that teaches the logic as well as the syntax rather than just showing what to type.

thanks in advance for the suggestions,
amit</STRONG>
Sorry to be a moron but I think you'll get the most mileage out of java. C is simple for basics but in my experience (I learnt Pascal many years ago and in principle they're the same thing but C has many tricks up it's sleave) you can get mental problems from lost pointers and bits of memory floating around in linked lists and stuff. You have to be very careful and you get some very strange errors from the compilers. Java *is* easier on the beginner after you grasp the basics. It handles stuff like memory for you, doesn't have pointers and let's you concentrate on doing actual programming.

Once you've gotten a handle on Java you can learn C very quickly as it isn't object oriented and the main things to learn will be pointers,structs,unions,typedefs and preprocessor directives. These are all prerequisites to learning ObjectiveC/Cocoa. ObjC is very similar in concept to Java with some added truly dynamic features but has a strange syntax.

C++ is very good for modern high speed applications and will allow you to programm for all platforms which ObjC doesn't (only OSX and Linux/GnuStep). But it has a ratty syntax, is conceptually different from most other OOP languages and has some tricks that make it not entirely compatible to C although it is supposed to be just a superset of the language.

If I'm speaking crap here, would some more knowledgeable developers please flame me.
weird wabbit
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:17 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2