Results 1 to 18 of 18

Thread: learning C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    zombologist Senior Member doc_bean's Avatar
    Join Date
    Oct 2004
    Location
    Riding Shai-Hulud
    Posts
    5,346

    Default learning C++

    Yes, another year, another programming language it seems. Last year it was Java, this year it will be C++. I don't think I'm going to do anything fancy with it. Luckily I just need it to control a robot (read data, apply filter, send data, etc.) , so it shouldn't be too hard...

    Currently, I'm looking for 3 things:

    *A (the ?) compiler, and whatever else I need to turn code into a working program.

    *An easy, to the point guide about C++. Since I'll probably focus on procedural programming, it doesn't need to be complete. I'm mostly interested in the syntax, basic structures and basic commands right now. Someone already recommended C++ for dummies to me, unfortunately my library doesn't have it so I'll have to check it out in a store. Anyone have any experience with this book ? Any other recommendations ?

    *A development platform. I used Eclipse for Java, but am unsure of how good its C++ support is. Plus it's sloooooow. Anyone know of a decent one for C++ ?
    Yes, Iraq is peaceful. Go to sleep now. - Adrian II

  2. #2
    Honorary Argentinian Senior Member Gyroball Champion, Karts Champion Caius's Avatar
    Join Date
    Aug 2006
    Location
    I live in my home, don't you?
    Posts
    8,114

    Default Re: learning C++

    Quote Originally Posted by doc_bean
    *A development platform. I used Eclipse for Java, but am unsure of how good its C++ support is. Plus it's sloooooow. Anyone know of a decent one for C++ ?
    Microsoft Visual Studio comes with Visual C++.I dont know if it good or not.

    Regards

    Caius




    Names, secret names
    But never in my favour
    But when all is said and done
    It's you I love

  3. #3
    zombologist Senior Member doc_bean's Avatar
    Join Date
    Oct 2004
    Location
    Riding Shai-Hulud
    Posts
    5,346

    Default Re: learning C++

    I need to program for Linux, so I'm going to avoid Microsoft products.
    Yes, Iraq is peaceful. Go to sleep now. - Adrian II

  4. #4

    Default Re: learning C++

    You may want to learn C first, unless you can already code in C?
    “The majestic equality of the laws prohibits the rich and the poor alike from sleeping under bridges, begging in the streets and stealing bread.” - Anatole France

    "The law is like a spider’s web. The small are caught, and the great tear it up.” - Anacharsis

  5. #5
    zombologist Senior Member doc_bean's Avatar
    Join Date
    Oct 2004
    Location
    Riding Shai-Hulud
    Posts
    5,346

    Default Re: learning C++

    Nope, I know Java and Pascal (although that's been a while). But I need to use C++, and I really don't have the time for indepth studies into C/C++.

    I suspect most of the code I will be writing will be C style (the non OOP component of C).
    Yes, Iraq is peaceful. Go to sleep now. - Adrian II

  6. #6

    Default Re: learning C++

    1. Since this is academia, my guess is just gcc. It will be available on whatever platform you will be writing your code. Hell, it runs on anything short of microwave ovens, and I think even that's under development.

    If you wanna code at home, and don't have/don't wanna install linux, then just install cygwin, and then install gcc under it.

    (note: in case you install a different compiler/gcc version at home, always make sure you test your code on the school compiler - this is always a problem with the students here: "but I tested this at home on <whatever other platform/compiler> and it was workiiiiing!")

    2. http://www.cppreference.com/ is a pretty good one, assuming you always have net access.

    As for books, whatever they recommended as the textbook; although, to be honest, I haven't touched a book in .... ages. I find that online help and reference sites are more useful/helpful than books, but, ofc, YMMV.

    3. well, I dunno, depends what you'll have installed on your lab machines.
    I recommend vi/emacs.
    Therapy helps, but screaming obscenities is cheaper.

  7. #7
    zombologist Senior Member doc_bean's Avatar
    Join Date
    Oct 2004
    Location
    Riding Shai-Hulud
    Posts
    5,346

    Default Re: learning C++

    Maybe someone can help me with this one. I need to have two linked `arrays`(I`m actually using a special vector class) I need to sort one and remember where each value went (in other words, if the elements would be numbered like 1-10, I`d need a new row like 9 5 6 ... telling me where they went after sorting).

    I`ve been able to implement a difficult solution to this problem but something tells me it should be easy...

    EDIT: anyone know how I can sort objects ?
    Last edited by doc_bean; 02-26-2007 at 17:46.
    Yes, Iraq is peaceful. Go to sleep now. - Adrian II

  8. #8

    Default Re: learning C++

    I'm utterly confused as to what you're trying to do. Why do you need two arrays ? Or you don't need them, but in your solution you felt you needed both of them ?
    Is it that you have the actual data in one, and their positions in the other one ? Is that the requirement of the problem, or is there any other reason why you want the two arrays ?

    Re sorting objects, normally, I guess you'd just overload a generic sort function, with a separate function for each of your object types.

    edit: a "simple" method, IF I understand correctly what you want (which I wouldn't bet money on), would be:
    1st array holds the elements you want sorted, 2nd array holds their positions (or pointers to them, or whatever you want).
    Whatever operation you do on the first array, do on the second array, as well. So, for example, let's say element 1 in array1 goes to position 3. Then you write 3 in element 1 in your second array.
    Or, say your sorting algorithm exchanges elements 3 and 6 in array1. Exchange the values of elements 3 and 6 from the second array.
    Does this make sense ?
    Last edited by Blodrast; 02-26-2007 at 22:42.
    Therapy helps, but screaming obscenities is cheaper.

  9. #9
    zombologist Senior Member doc_bean's Avatar
    Join Date
    Oct 2004
    Location
    Riding Shai-Hulud
    Posts
    5,346

    Default Re: learning C++

    Quote Originally Posted by Blodrast
    I'm utterly confused as to what you're trying to do. Why do you need two arrays ? Or you don't need them, but in your solution you felt you needed both of them ?
    Is it that you have the actual data in one, and their positions in the other one ? Is that the requirement of the problem, or is there any other reason why you want the two arrays ?

    Re sorting objects, normally, I guess you'd just overload a generic sort function, with a separate function for each of your object types.

    edit: a "simple" method, IF I understand correctly what you want (which I wouldn't bet money on), would be:
    1st array holds the elements you want sorted, 2nd array holds their positions (or pointers to them, or whatever you want).
    Whatever operation you do on the first array, do on the second array, as well. So, for example, let's say element 1 in array1 goes to position 3. Then you write 3 in element 1 in your second array.
    Or, say your sorting algorithm exchanges elements 3 and 6 in array1. Exchange the values of elements 3 and 6 from the second array.
    Does this make sense ?
    I think you got it, sorry if I wasn`t clear, it had been a long day

    Anyway someone gave me a piece of code that should solve the trick, the idea was indeed to just overload a basic sort functon and write similar code that does the same operation on 2 vectors, I had thought there would have been an easier way. Don`t waste too much time looking for the easy way out I guess
    Yes, Iraq is peaceful. Go to sleep now. - Adrian II

  10. #10

    Default Re: learning C++

    On the contrary, you should be glad you did it the right, and elegant, way.
    Therapy helps, but screaming obscenities is cheaper.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO