This forum is in permanent archive mode. Our new active community can be found here.

Learning C++, any suggestions?

edited August 2007 in Everything Else
Hey guys! I'm currently in Computer Science 2 (College Level, Honors) as a Freshman. Unfortunately, my expertise is JAVA...so I don't know too much about C++. This means I'm practically 2 years behind! Why did I have to learn JAVA and get a 4 in the Computer Science AP test...and then end up being thrust into the world of C++? I'm a little nervous, but I have come to the realization that I have allies on my quest to learning this language.

Do you guys have any suggestions? What are good C++ compilers? Where should I start? I'm good with programming concepts in general, but the actual specific language of C++ is unfamiliar to me. Halp?!

Comments

  • Can't help you with much except a compiler. DevC++
  • Thanks for that. Is it the most efficient and noob-friendly compiler out there right now?
  • If you understand the fundamental principles of object oriented programming and design, you should be able to pick up an d use any object oriented programming language. Granted, C++ has some pretty arcane syntax, especially if you use the STL. However, it's still object oriented, and you can look up the syntax crap in a book that has an animal on it.
  • That's good to hear. I've been looking through some C++ tutorials online and I'm understanding the concepts fairly well, but I still don't know how far behind I am. Also, Scott, what C++ Compiler do you use in your workplace (if you use one)?
  • edited August 2007
    I'm gonna take a wild stab here and say that based on what he's said in past podcasts Scott probably uses the GCC compiler in linux.
    Post edited by raquor on
  • C++ is a cakewalk. Do some Google searches and whatnot for some sample code and just read.
  • I don't use C++ at work. But raquor is correct, gcc/g++ is the way to go.
  • It's not just learning C++ though, you will also (likely) need to learn a toolkit to go with it.

    If you are going to get into programing for GUI systems I suggest you look into wxWidgets. It is a cross platform system that you can compile to work with Mac, *Nix and Windows.

    Stay away from MFC (Microsoft Foundation Classes) until you have mastered the core of the language and the API you are working with. You can code faster using those systems but when something goes wrong you may find yourself unable to fix it or even understand why it went wrong.
  • you can look up the syntax crap in a book that has an animal on it.
    Sorry for the off topic post but this slayed me.
  • I'm getting Visual Studio 2005 from my University. Is that any good?
  • edited September 2007
    I'm getting Visual Studio 2005 from my University. Is that any good?
    I assume you are using Windows then. I have not personally used Visual Studio, but I've heard very good feedback from close sources. I, in Windows, use Visual C ++ 6.0 [yes, a bit old school]. Although, I believe they are similar. In Ubuntu, I run gcc/g++, for my programming.
    Post edited by Zeehat on
  • I use VS2005 on a daily basis at work. It is significantly better than previous versions of said IDE. It still has it's quirks but it's a solid development environment and pretty much the most together one for windows, particularly if you want to be able to debug in the IDE. You're supposed to be able to debug in DevC++ but I could never get it to work...it required too much extra BS.
  • Ugh, VS2K5 is sucking on Vista.
  • edited September 2007
    Here's my very first assignment!!!
    Assignment 1 Due date: 9/21/07
    Given a class named dateType that has the following properties:

    Data members (all of them are whole numbers)

    mm: month of the date
    dd: day of the date
    yy: year of the date

    Member functions

    setDate(months, days, years)
    //Function to set the date
    //The date is set according to the parameters
    //Postcondition: mm = months; dd = days; yy = years
    // The function checks whether the values of months, ,
    // days and years are valid. If a value is invalid,
    // the default value 0 is assigned.

    getDate (months, days, years)
    //Function to return the components of the date
    //Postcondition: months = mm; days = dd; years = yy

    printDate()
    //Function to print the date
    //Postcondition: date is printed in the form “mm/dd/yyyy”

    incrementDate()
    //Function to increment the date by one day.
    //Postcondition: The date is incremented by one day
    // If after incrementing the day, its value goes beyond the last
    // day of the month, the day is reset to 1 and the month incremented by one.
    // If the month goes beyond the last month of the year, it is reset to 1
    // and the year incremented by one.

    daysToDate(otherDate)
    //Function to return the number of days between two dates.
    //Postcondition: Returns the number of days between self and otherDate
    // as a whole number. The number returned is an absolute value.

    dateType(months=1, days=1, years=1900);
    //Constructor with default parameters
    //The date is set according to the parameters.
    //Postconditions: mm = months; dd = days; yy = years
    // The constructor checks whether the values of months,
    // days, and years are valid. If a value is invalid,
    // the default value (1 for days and months, 1900 for years) is assigned.



    declare and define it and then write a client program for testing it.

    The class must have the members described above and you have to determine the data types for the parameters and function values.
    Wish me luck! :D
    Post edited by VentureJ on
  • Ugh... that is hurting my head reading it...

    But I wish you luck!
  • That's not too tough. The only long part will be setting up the "how many days in a month" check. I say long not hard because it will take you longer to write the check code than to think it up.

    I remember when my wife came home from school one day with a programming assignment about writing a personal banking program that had to cover mortgages and interest rates and compounding those interest rates. she was none too happy with the assignment.

    The trick with writing code is being able to figure out the optimal way to do something and then be able to translate that into computer code.

    Let me give you one tip that may help you: Create a private function for checking the validity of the date input that each public function can call on.

    Oh yes, is this meant to be a GUI program or a console program?
  • Hrm... I should finish reading the ebook version of C++ in 21 days. The stuff I've already read of it gave enough to understand and 'sketch' your assignment :D

    The days to date I have yet to see, but as for the increment date... Fun assignment. Good luck
  • edited September 2007
    Finished. Took me 2 hours! :D

    It was actually very easy. Thank you guys for your help!

    Edit: It was merely console. The hardest part was implementing Julian something-or-other for the daysToDate function.
    Post edited by VentureJ on
  • You know I've been thinking about trying to learn programming... I just want to take a stab at it, it's something I'm interested in, but you never know, it might not be my thing.
     
    What should I learn to start? What's the most basic (is it BASIC?) to learn, and what do I need?
  • C++, or Java. Hey! Learn C++ with me!

    (Though I already grasp the general concepts...and the programming itself is quite similar. Maybe I'd have a head start?)
  • Yeah, I don't know shit. I talked to a programmer earlier this month, and it's something I really want to TRY and learn.
  • edited September 2007
    Mitchy D, a great ebook that I used for starting programming is How To Think Like A Computer Scientist. Rym and Scott have recommended it before, I believe. An alternative to that would be Why's Poignant Guide to Ruby, which is not as good, but is much more ADD if you are having trouble holding your attention with HTTLaCS. Either of these books should give you a good idea of what programming is like and if you enjoy it or not.
    Post edited by Sail on
  • Thanks Sail. I'll look in to it.
  • You did remember Leap Year, right?
  • Of course. It was very easy.

    If (year % 4 == 0)
    ....etc
  • Of course. It was very easy.

    If (year % 4 == 0)
    ....etc
    I know it is easy but some people simply forget to account for it.
  • People who forget leap years in an assignment like this should rethink their class selection.
  • edited September 2007
    Of course. It was very easy.

    If (year % 4 == 0)
    ....etc
    Do you realize leap year is much more complicated by that?

    Every 4 years is a leap year. Unless it is divisible by 100, then it is not a leap year. Unless that is divisible by 400, then it is a leap year. So the year 1900 was not a leap year, even though by the rule of 4's it should have been. And, along with that, 2000 was, even though it is divisible by 100 due to the fact it was divisible by 400. I noticed that the default year you gave was 1900, so just thought I'd give my 2 cents. This issue is due to the fact that the world revolves the sun every 365.242375 days. They current way of doing leap years places it close (but not quite) at that measuring an average of 365.2425. I dunno if your teacher will actually look that far into it, but still good to know.
    Post edited by Tasel on
  • Tasel's post on leap years
    Woaaaw... never knew it was that complicated. So... if it's dividable by 400 or 4, but not by 100, it's a leap year. if (year % 4 == 0 AND year % 100 != 0 OR year % 400 == 0) etc...

    Hmmmm... Let's hope I'll remember that if I ever get a similar assignment.
  • Whatever. I still got full credit for that.

    Thanks for the help, though. THIS is why I post here.

    :D
Sign In or Register to comment.