Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
hi, absolute newbie here,

I've just enrolled Programming fundamentals in C++ this summer

I've read that Objective C++ is a good developer to learn.. i have a macbook laptop (leopard 10.5.2)

now what do i need and where do i find it to get me started :)


thank you for taking time guys more power to you all!


hope i'll enjoy and learn C++ basics thi summer it really looks hard:-(
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
You mean the Objective C++ language? It's not a good first language to learn. In fact, it's not really a separate language. It's an idiom that mixes Objective C and C++, but the mixture is somewhat restricted, and to understand what's allowed and what isn't, you need to know both Objective C and C++ fairly well. As a language, it's really meant for carpetbagging C++ programmers moving over into Objective C.

I think you perhaps mean development environment? If this class you're taking has any taste, it'll all be in UNIX, writ and compiled in the terminal, but I'm betting it'll be Windows which means Visual Studio which means a heavyweight non-portable IDE that's almost as much effort to learn as the language itself.
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
hi, yes its in visual studio... is there a version for mac? or what do you suggest i use for learning C++ in my class using macbook..

thanks :)
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
If the class is in Visual Studio, then you'd need VMWare or Parallels running Windows. Visual Studio doesn't exist for Mac.

Apple's Xcode is the rough Visual Studio equivalent for OS X. It's a lovely piece of software, but like all IDEs, it's a complex, peculiar beast whose virtues aren't really apparent until your projects' complexity starts to scale (hundreds of files, multiple build versions, etc.) . Before that point is reached, it has a tendency to just get in the way.

I'd suggest, as a counterpoint and astringent to the MS way of doing things, pursuing a parallel learning path and get to know the UNIX layer of your Mac. Learn how to edit, compile, run, and debug programs from the command line, outside an everything-and-the-kitchen-sink IDE. Doing so you will have a much keener sense of what's going on behind the scenes, and you'll be a better programmer in the end.
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
hi, what do you mean by exploring the unix layer of my macbook?
Im trying to download the xcode (leopard) from apple will this do in school?

sorry for my newbie questions:( i really need to get started otherwise i'll might change my this subject for another one, i have till tommorow to withdraw the course..(i hope i wont come to this)

i it will help.. this is the book we are using C++ How to Program", by Deitel and Deitel, 6th edition.

please direct me to a software where i can use in my macbook:confused:


thank you again:D
 

sonyc148

macrumors newbie
Oct 26, 2007
10
0
1) If you want to code for macosx, you can:
- use you Leopard install disc (if I remember correctly, XCode 3 can be installed from your Leopard install disc)
- or, if you have lost your Leopard install disc, download xcode 3 on the apple website (http://developer.apple.com/tools/download/)

Once you have downloaded XCode, you can follow the tutorial in the following to create your first macosx application:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/01Introduction/chapter_1_section_1.html

You can (and should) also read the book available at: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ObjC.pdf
It is the complete specification of the Objective C 2.0 language.

If you are taking a course about Visual C++, learning XCode/Objective-C 2.0 won't help you much. It is still an interesting exercise, as it will make you:
- aware of the alternatives
- more critical about Visual C++ (meaning that knowing other ways to do something can often lead you to having original ideas to solving problems)
- better at coding in general
But it is an exercise I would leave for later. I wouldn't recommend on learning XCode/Objectice-C 2.0 as your first language.

2) If you want to code for windows, or if you want to learn a little Visual C++ before taking your class, you will have to install windows xp on your macbook (no need to install vista). Use bootcamp for performance reasons (visual studio IDE is quite heavy in terms of ressources).

Once windows xp is installed on your macbook, you can download a "free for personnal use" version of Visual Studio C++. Use the following link to download the Visual Studio C++ Express Edition: http://www.microsoft.com/express/product/default.aspx

To learn about Visual Studio C++, you can use the following links (warning: if your browser is displaying an empty page when trying to follow those links, just try in another browser; I had problems navigating this site on firefox/safari, but not on internet explore 6):
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-0-installing-microsoft-visual-c++-2008-express-edition.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-1-creating-your-first-hello-world-program-in-the-console.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-2-building-on-the-hello-worl-application-with-input-and-outpudt.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-3-an-introduction-to-variables-and-constants.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-4-introduction-to-data-types.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-5-understanding-logical-operators.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-6-understanding-relational-operators.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-7-introduction-to-if-else-if-else.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-8-introduction-to-while-and-do-while-loops.html
http://www.videotutorialzone.com/development-tools/visual-c++/microsoft-visual-c++-lesson-9-tic-tac-toe.html

C++ is quite hard to learn if this is your first programming language, but it's not impossible. If you have the choice, I would recommend learning C#, as it is slightly easier.

You should also look for articles on the internet, to understand what OOP is (Object Oriented Programming, as opposed to Structural Programming).

If you don't know anything about programming, don't be afraid if the learning curve is quite slow at the beginning. The main things you need to keep doing are:
- experiment
- read
- ask
- (repeat the three tasks above)

The internet is full of tutorials/blogs about programming stuffs in general, so learn to master google, and do your own research ;)
When you are following a tutorial, don't give up if you don't understand everything. Follow the instruction, and once you have finished the tutorial, look back at what you did and see if you can make sense of what the tutorial was trying to demonstrate.

After following some tutorials, try to find something easy that you would like to code (something like a dvd collection application to keep track of your dvds, or an application where you can store/edit/display recipes, ...), and spend the time needed to code it. If you get stuck and don't know how to do something, google is your friend.

After the few hours/days/weeks, depending on your current knowledge, your will start learning new coding stuffs pretty fast, so the main advice you can get is: don't give up.

Good luck.
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
hi, im not really trying to specifically code for mac or windows yet, just trying to learn the language first.. I've installed xcode, it really looks intimidating and its like for advance user only:eek:


can i just enter like few basic C++ examples from my book and get results like the classic..

#include <oistream>

int main()

{

std::cout <<"hello world"\n;

return 0;

}

// got so many errors on this by the way... what i did by the way is, i created a new project, choosed standard carbon c++.. then ecoded the above..

or did i do it wrong?


the book mentioned about GNU C++ went to their site but cant find the download link... can anyone help me with the link?


by the way i decided to not drop the subject.. im thinking this will really hurt my gpa:D

thanks again for taking time!!
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Forget about xCode completely.

Enter your code in a text editor (it's iostream not oistream, not sure if that's an issue at this point) and save it.

use g++ from the terminal. OS X already has the GNU compilation tools.

If your file was saved as helloworld.cpp, you'd run:
g++ -o helloworld helloworld.cpp
./helloworld

To compile and run your program.

Do not use an IDE like xCode yet. if you HAVE to use VC++ at school, so be it, but try to learn how to do things with the command line tools at the beginning.

-Lee
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Hi

Now i would recommend the opposite, ie use Xcode. Start a new project and select Command LineUtility, C++ tool. There's your hello world program ready for you to compile and run. You can take it from there. Once you get the basic understanding of how Xcode works (and it's not that difficult for simple stuff) you can concentrate on learning/experimenting with C++. If you decide you want to take learning C++ seriously, you can start digging into the command line, compiler options, linkers etc. But for simply trying out stuff from your book, I would say use Xcode.

b e n
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
found the xcode with the hello world code,

pasted my code from the book, how do i view/run it
-i did clicked the build and go and run in the menu, it says it succeeded but i seem not to see the window/view of my "hello world":D


thank you so much guys!
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
hi guys im already starting with C++ using xcode-- thanks for all your help!

yep i know my problems does not end here but actually the opposite, if you know what i mean:D

dont get me wrong im having fun!:)

you see im having this problem with the output..

i must come up with this result on screen, having to input 3 integers.

sum:
ave:
product:
smallest:
greatest:

- now my problem is i keep on having two results of smallest or greatest..
what did i do wrong?


thanks guys:D
 

Attachments

  • capture1.png
    capture1.png
    85.2 KB · Views: 84
  • capture2.png
    capture2.png
    62.6 KB · Views: 109

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
hi guys im already starting with C++ using xcode-- thanks for all your help!

yep i know my problems does not end here but actually the opposite, if you know what i mean:D

dont get me wrong im having fun!:)

you see im having this problem with the output..

i must come up with this result on screen, having to input 3 integers.

sum:
ave:
product:
smallest:
greatest:

- now my problem is i keep on having two results of smallest or greatest..
what did i do wrong?


thanks guys:D
 

aross99

macrumors 68000
Dec 17, 2006
1,540
1
East Lansing, MI
I think you have an error in all of the IF statements with the "and" parameter - I am surprised you didn't get a syntax error.

instead of this:

Code:
if (number1 < number2 and number3)

I think you want something like this:

Code:
if (number1 < number2 && number1 < number3)
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I think you have an error in all of the IF statements with the "and" parameter - I am surprised you didn't get a syntax error.

instead of this:

Code:
if (number1 < number2 and number3)

I think you want something like this:

Code:
if (number1 < number2 && number1 < number3)

In C++ "and" is (can be?) a reserved word that can be used in place of a logical and (&&). As such the syntax was valid, but there was a logic error. The code amounted to, in English:
If number1 is less than number 2 and number3 is not equal to 0

I'm sure your assumption about the intention is correct, but wanted the OP to understand what he was expressing the way his code was.

-Lee
 

aross99

macrumors 68000
Dec 17, 2006
1,540
1
East Lansing, MI
I figured it was something like that since it wasn't flagged as a syntax error. I'm afraid I am an old-time C programmer, and not up to speed on these "new" C++ conventions. :)

Good to know though...
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
yep thats what i think thought so too.. there is something wrong with my grammar or logic...

its kind of funny how the smallest gives out single result and the greatest gives two..but sometimes 1...

any suggestions on how to make it work?
 

aross99

macrumors 68000
Dec 17, 2006
1,540
1
East Lansing, MI
yep thats what i think thought so too.. there is something wrong with my grammar or logic...

its kind of funny how the smallest gives out single result and the greatest gives two..but sometimes 1...

any suggestions on how to make it work?

Try making the changes I suggested, or using "and" in place of the "&&" and I think you will be happy with the results...
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
product = number1 * number2 * number3;
cout << "product is:" << product << endl;

//smallest = number1 < number2 and number3;
//cout << "smallest # is:" << smallest << endl;

if (number1 < number2 && number3)
cout << "smallest:" << number1 << endl;

if (number2 < number3 && number1)
cout << "smallest:" << number2 << endl;

if (number3 < number1 && number2)
cout << "smallest:" << number3 << endl;

//greatest = number1 > number2 or number3;


if (number1 > number2 && number3)
cout << "greatest:" << number1 << endl;

if (number2 > number3 && number1)
cout << "greatest:" << number2 << endl;

if (number3 > number1 && number2)
cout << "greatest:" << number3 << endl;

return 0;

}

// hi, this is what i did..

//still got this result..

The Debugger has exited with status 0.
[Session started at 2008-06-13 22:58:05 -0500.]
Please enter 1st number: 34
Please enter 2nd number:3
Please enter 3rd number:2
sum is:39
ave is:13
product is:204
smallest:2
greatest:34
greatest:3
 

aross99

macrumors 68000
Dec 17, 2006
1,540
1
East Lansing, MI
Go back and take a look at what I showed you - you didn't copy it correctly...

Programming like this is all about the details. One little error and things that you think are OK, can be completely different. These types of bugs are very hard to find also, because you typed what you MEANT to, but it doesn't do what you THINK it does.

Look at my example again and you will see what you did wrong...
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
thanks! i got it i have single result in the greatest integer...

however it's not giving me the highest value..

//output

The Debugger has exited with status 0.
[Session started at 2008-06-13 23:36:33 -0500.]
Please enter 1st number: 34
Please enter 2nd number:23
Please enter 3rd number:56
sum is:113
ave is:37
product is:43792
smallest:23
greatest:34

The Debugger has exited with status 0.
[Session started at 2008-06-13 23:39:23 -0500.]
Please enter 1st number: 23
Please enter 2nd number:34
Please enter 3rd number:56
sum is:113
ave is:37
product is:43792
smallest:23
greatest:34

//code
product = number1 * number2 * number3;
cout << "product is:" << product << endl;

//smallest = number1 < number2 and number3;
//cout << "smallest # is:" << smallest << endl;

if (number1 < number2 && number1 < number3)
cout << "smallest:" << number1 << endl;

if (number2 < number1 && number2 < number3)
cout << "smallest:" << number2 << endl;

if (number3 < number1 && number3 < number2)
cout << "smallest:" << number3 << endl;

//greatest = number1 > number2 or number3;

if (number1 > number2 && number1 < number3)
cout << "greatest:" << number1 << endl;

if (number2 > number1 && number2 < number3)
cout << "greatest:" << number2 << endl;

if (number3 > number1 && number3 < number2)
cout << "greatest:" << number3 << endl;

return 0;

}
 

wlh99

macrumors 6502
Feb 7, 2008
272
0
thanks! i got it i have single result in the greatest integer...

however it's not giving me the highest value..

//output

You are finding the middle number. Look at aross99's example again. While doing so consider the following English statement.

"If number one is greater than number two, and number one is also greater than number three, then number one is the greatest."
 

adrix7

macrumors newbie
Original poster
Jun 10, 2008
22
0
oh my god how did i miss that! due to my laziness i copy and paste those commands (smallest and greates) thats why i've retained the < less than character :D


got to be careful next time! learned my lesson:eek:

by the way does anybody have a link to a C++ dictionary or something conicise to help me understand terms..?


thank you again guys! now im on to chapter 3 at last!!!
 

aross99

macrumors 68000
Dec 17, 2006
1,540
1
East Lansing, MI
Congratulations on getting your program to work. :)

As far as a C++ dictionary, I would suggest googling for one, or for the terms you are looking for...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.