C++ ii 2/16/08

Tired of listening to your instructor tell stories about his daily visit to a perfume store? Wonder when your going to get a "hands on" approach?

C++ ii 2/16/08

Postby sevenalive » February 16th, 2008, 2:23 pm

Well today we just got the last step in our Array Project and we are going to do a vector array.
I understand the need to teach inheritance and polymorphism but seriously lets do a real world use.

First of all he had us use a generic type name for our array class so we can use any data type, which is fine but the class is set up to only use ints and doubles. So why not make it just a double type, which allows but ints and doubles.

Then we are doing this vector array thing and its just a copy of the class and 2-3 changes (just adding vector to the vars)
As far as i understand, the only difference is that it makes it dynamic.

Anyway, this is my last c++ class and we didn't touch managed c++ and GUI.
If you don't like it, MOD IT!
User avatar
sevenalive
Administrator
 
Posts: 594
Joined: February 6th, 2008, 11:42 pm
Location: Arizona
ITT Campus: AZ - Phoenix (Tempe)
Still attending: No

Advertisement

Re: C++ ii 2/16/08

Postby masamune » February 26th, 2008, 2:50 am

C++ as you know has different types. Having different types allows the compiler to check the correctness of your program. Some types are able to be implicitly converted (such as ints and doubles). However, there is a differnce between those types. As you know doubles store an approximation of a decimal number while integers store a whole number. Doubles can not exactly store all integers. While for simple uses this appears not to make a difference, in practice it makes a huge difference. It is definantly a source of hard to track down bugs.

Also remember some projects are deisgned to give you problems to practice specific skills. These skills may be applable directly to a job. Polymorphism is used almost everywhere you use C++. Templates are likewise used everywhere you use C++. Understanding how a template is used helps you use other developer's classes that also use templates. For example the STL consists mostly of templated classes.

The switch from arrays to vectors is simple. In practice it means that you no longer have to worry about array bound when storing items and retreiving items. If you did not know how many items would enter your array, this would reduce the amount of code that you needed. Another benefit is that it can make it easier to switch the type of container. Switching from a std::vector to a std::list requires changing only the type of the variable and not the remainder of your code. In turn this helps you encapsulate classes that you create yourself.

Finally, managed C++ is a different language than C++, so I can't say that its really an issue that you did not learn it. GUI programming requires a much deeper knowledge base than using arrays, so it seems like something that wouldn't be covered in the course.

Good luck.
masamune
 
Posts: 6
Joined: February 26th, 2008, 2:08 am


Return to Classes and Instructors

Who is online

Users browsing this forum: No registered users and 1 guest

cron