Exploring Operator Overloading w/ Jamie King's Code

  • Thread starter yungman
  • Start date
  • Tags
    Operator
In summary: The code above would appear to have been written by someone who is unaware that every class member function has an implied first parameter, a pointer to the class instance.
  • #36
Looks like our electrons passed each other somewhere in the interwebs. :smile:
 
Technology news on Phys.org
  • #37
Thank you Jtbell. I just want to verify. I don't want it to work just in certain case and give problems later.

Thanks
 
  • #38
FactChecker said:
I suggest that you search this forum for "learn python" and look at some of the threads. Also, there are many youtube videos that get to interesting applications quickly (in an hour). I would not recommend that you concentrate on HTML as a programming language unless you are primarily interested in designing web pages.
Thanks

I look into a little about Python, it's like another language different from C++, I have to spend at least a few months to get to where I am at on C++. I might be better off keep at the C++ to get to higher level.

My question might sound funny...when is C++ gets to be fun?! So far 5 months and almost studied the whole book of Gaddis brief version, all I have to show for is doing something on cmd window. I am planning to complete the last chapter on Inheritance and Polymorphism. Then one more on Template and some Library. How much more I have to study before I can be ready to do some fun stuffs?

I read a lot of games, drivers and others are written in C++, I chose C++ because it's consider the most popular language. It got to be more than just writing some stupid spread sheets, employee info, phone and address directory type of stuffs...specially only in cmd window.

Thanks
 
  • #39
yungman said:
Thanks

I look into a little about Python, it's like another language different from C++, I have to spend at least a few months to get to where I am at on C++. I might be better off keep at the C++ to get to higher level.

My question might sound funny...when is C++ gets to be fun?! So far 5 months and almost studied the whole book of Gaddis brief version, all I have to show for is doing something on cmd window. I am planning to complete the last chapter on Inheritance and Polymorphism. Then one more on Template and some Library. How much more I have to study before I can be ready to do some fun stuffs?

I read a lot of games, drivers and others are written in C++, I chose C++ because it's consider the most popular language. It got to be more than just writing some stupid spread sheets, employee info, phone and address directory type of stuffs...specially only in cmd window.

Thanks
Did someone tell you that C++ was fun? I never thought that it was fun, although I loved some of the object-oriented concepts that it was geared for. IMHO, it has always been for serious work (seriously hard). It does allow you to use packages and libraries for graphics, etc. that you might consider fun to use. Personally, I would not write C++ programs for fun.
 
  • #40
FactChecker said:
Did someone tell you that C++ was fun? I never thought that it was fun, although I loved some of the object-oriented concepts that it was geared for. IMHO, it has always been for serious work (seriously hard). It does allow you to use packages and libraries for graphics, etc. that you might consider fun to use. Personally, I would not write C++ programs for fun.
Thanks

yes, that's part of it, I even bought the graphic with C++ book by Gaddis. I just wonder when will I consider ready to move onto that. How much more boring chapters I have to study before I can jump onto that.

Also, I was thinking something even more interesting to me, how to write dll and interface with Windows. I want to learn more about the inner workings of Windows. I never into gaming, so graphics is really secondary. I really want to learn more about windows, how to interact with windows. I still have some old laptops with XP or Window 7 I can afford to screw them up when I dig into the Windows. Hell, If I can learn this, I don't even mind spending a few hundred dollars to buy a new laptop and screw it up!

One thing I can think of is study IT, or taking a class on IT. But I really don't know enough what is the best way to do this. Any suggestions?
Also, I've been searching on line which program is the most popular now a days. They are say Python by a lot. Is Python like fashion that is "in" today and might fade. Another reason I decided on C++ is it's been around for a long time and still very popular. I don't want to invest my time on anything that is "fashion". I've seen languages come and go.

Thanks
 
Last edited:
  • #41
yungman said:
Thanks

yes, that's part of it, I even bought the graphic with C++ book by Gaddis. I just wonder when will I consider ready to move onto that. How much more boring chapters I have to study before I can jump onto that.

Also, I was thinking something even more interesting to me, how to write dll and interface with Windows. I want to learn more about the inner workings of Windows. I never into gaming, so graphics is really secondary. I really want to learn more about windows, how to interact with windows. I still have some old laptops with XP or Window 7 I can afford to screw them up when I dig into the Windows. Hell, If I can learn this, I don't even mind spending a few hundred dollars to buy a new laptop and screw it up!

One thing I can think of is study IT, or taking a class on IT. But I really don't know enough what is the best way to do this. Any suggestions?
Also, I've been searching on line which program is the most popular now a days. They are say Python by a lot. Is Python like fashion that is "in" today and might fade. Another reason I decided on C++ is it's been around for a long time and still very popular. I don't want to invest my time on anything that is "fashion". I've seen languages come and go.

Thanks
These topics are straying off the original thread topic of operator overloading and cover a lot of ground. I suggest that you search the forum and look at some of the old threads on these subjects.
 
  • #42
yungman said:
How much more I have to study before I can be ready to do some fun stuffs?
I read a lot of games...

If you wanted to learn to program games, why the devil did you pick Gaddis? If you look at the index, the word "game" or "games" isn't even listed? (There are some games in the problems, like Tic-Tac-Toe)

In July, you asked what language to learn. People suggested Python. You ignored their advice. Now it turns out they were right. How is this our fault? (I know...we were insufficiently convincing)

Finally, if you can't write a game in Fortran, or Pascal, or whatever, switching to C++ won't magically make you able to do so. Just like switching word processors won't make someone a poet.
 
  • #43
If Python is the "fashion of the day", then it is at least the "fashion of the last decade". As such, it has accumulated a very large base of libraries for fun hobbies, user communities, development environments, etc. How long that will last is not for me to know. Eventually, something else will come along, but you will still be able to use Python and enjoy it.
 
  • #44
"What is C++ going to be fun"?

This made me chuckle. I would guess never. It's such a large, messy language--brilliant though it was for its time--that, in my experience, programmers in the past often specialized in C++ only, or avoided it mostly. I was the latter. When I had to have C++ back in the day, I asked someone else to do it. Instead, I learned dozens of other languages, all of which were easier to master than C++.

That is, of course, entirely a subjective opinion. I certainly wouldn't blame you for moving on. If you move on to one of the languages that share almost identical syntax with C++ (i.e., Java or C#), you may find them easier to "master" and quicker to reach a point of being able to do something satisfying. It's so easy to do graphics in either language, for example, that I sometimes made it a first homework assignment (in either language) for students to create a "self portrait" using simple graphics. The results were always wonderful, as students would knock themselves out to create graphics. Then I would move on to things like a bubble box (with random colored and sized bubbles floating in a box). All that would take so much longer to learn using C++ that it's almost unfathomable.
 
  • Like
Likes FactChecker
  • #45
If you switch to another language, it is not as much of a setback as you might imagine. The concepts you have learned are easy to find in other modern languages and often easier to implement. The syntax differences quickly become natural. C++ is not a forgiving language. I know some very expert programmers who prefer other languages. That being said, I think that a lot of the problems that you have had with C++ in these forums would have also given you trouble in the other languages. There is just a lot to learn.
 
  • #46
Thanks guys for the input. The reason I chose C++ was because when I was working, we used C++ for all the firmware, it's the language most EE use for testing and all. It is faster than Python and easier to control for time critical situation. Don't tell me speed is not important. In low level firmware, speed can be everything and I always wonder why don't we write the timing critical part in assemble like before.

I never find C++ is hard in programming, what I find hard all along is the names, the terms, all the instance, object...those names that I got lost in reading. Now that I am more familiar with the names, particular I find watching youtube video really help. It's NOT what the program do that is hard, it just a lot of small little things to remember like the tv show called "Million little things"! Nothing hard, just a lot. Then together with unfamiliar names, that made it so hard for the first 3 months.

My question to you guys is whether other languages like Python use the same names and terms that I don't have to learn everything new again? Or they have their own lingo that is different from C++? If it is the same, then it would be a whole hell of a lot easier. Like I said, it's NOT that it's hard to learn C++ for me, it's the names. Now that I find it a lot easier to learn C++, it's hard to start all over again.Lastly but not the least and is VERY important in my life. Do you mean some of you in so deep into programming and work with C++ and don't find it fun?! It is my STRONG held believe that you got to enjoy what you are doing and it's fun if you work in the field in your career, or else might as well KMN. It is my strong hold believe that if I go into a career, I better LOVE IT. My degree was Chemistry, I never worked a day in Chemistry. I was good at it too. I got straight A's in all the lectures in 4 years. But I found I hated doing lab work, I just quit. I was doing pizza deliver after college and refused to look for a job in Chemistry. I determined to find something I love as my career.

I was a good musician at the time too. Before I came here, I won 4 talent quest and was performing on tv and stadiums. I thought that was my true love. Then I found Electronics, one day, I just packed up my guitar and did not open the care for like 15 years because I was so in love with electronics I don't have time for that anymore. I found my true passion of my life. I spent almost 30 years in the field. After I retired, I still study for a few years just for the hell of it because I enjoy it.

I got into designing high end audiophile amps, my amps I designed and built can compare with amps of $5K+ from people that came and listen. I am taking a break to learn something new as I need something to challenge my mind right now, that's where C++ comes in. I am still going to go back to electronics in the future. I cannot imagine someone that don't like their jobs and not finding it fun and work 40+hours day after day, year after year. Money has NOTHING to do with it.
 
  • #47
yungman said:
Thanks guys for the input. The reason I chose C++ was because when I was working, we used C++ for all the firmware, it's the language most EE use for testing and all. It is faster than Python and easier to control for time critical situation. Don't tell me speed is not important. In low level firmware, speed can be everything and I always wonder why don't we write the timing critical part in assemble like before.
Don't you think we know all this? It didn't sound like you intended to work on hard real-time applications, let alone device drivers. You are free to follow your own advice, but then don't complain about what you get. We tried to warn you. I am "unfollowing" this thread.
 
Last edited:
  • Like
Likes Vanadium 50
  • #48
FactChecker said:
Don't you think we know all this? It didn't sound like you intended to work on hard real-time applications, let alone device handlers. You are free to follow your own advice, but then don't complain about what you get. We tried to warn you. I am "unfollowing" this thread.
I said that was why I decided to go with C++ at the time. Maybe it's a mistake. I don't know what I want at the time, I am not even sure I know what I want to do with programming yet. One thing you are right, I don't intend to do firmware stuff at this point.
 
  • #49
yungman said:
Lastly but not the least and is VERY important in my life. Do you mean some of you in so deep into programming and work with C++ and don't find it fun?! It is my STRONG held believe that you got to enjoy what you are doing and it's fun if you work in the field in your career, or else might as well KMN.
I find it fun. It might be different if I were writing code as my day-time job, with time pressures forcing me to produce X lines of debugged code per day. In the past, in one of my careers, I wrote code for a living, primarily in C#, but in my other career I taught a variety of programming classes, including Basic, Fortran, Modula-2 (once, but not Pascal), C, and C++. I am technically retired, but have been teaching a couple classes a year at a nearby college, and have become the go-to guy for our Computer Architecture course, which heavily uses MIPS assembly.
Just for fun I try to come up with somewhat realistic applications that combine C++ and assembly, particularly Intel AVX-512 instructions, some of which are not described anywhere other than in the Intel documentation, and not very well at that.
 
  • #50
Mark44 said:
I find it fun. It might be different if I were writing code as my day-time job, with time pressures forcing me to produce X lines of debugged code per day. In the past, in one of my careers, I wrote code for a living, primarily in C#, but in my other career I taught a variety of programming classes, including Basic, Fortran, Modula-2 (once, but not Pascal), C, and C++. I am technically retired, but have been teaching a couple classes a year at a nearby college, and have become the go-to guy for our Computer Architecture course, which heavily uses MIPS assembly.
Just for fun I try to come up with somewhat realistic applications that combine C++ and assembly, particularly Intel AVX-512 instructions, some of which are not described anywhere other than in the Intel documentation, and not very well at that.
That's what I expect people here would say! You guys spent the whole career on this and still come here to help. You got to love it and find it's fun. I was surprised when some people that worked on C++ said C++ is not fun. I would quit if I find what I studied and doing is not fun. There got to be something fun about C++ if someone spend their career working on it. Like you obviously is expert on C++, you got to like it to stay with it. That's the reason I asked the question when is C++ start to be fun in post 38.

My question is more like how much more I need to study all the dry stuffs before I am ready to venture out to do things with C++. I remember you said the minimum is to cover chapter 13 and chapter 14 up to overloading operators a while back. I am studying overloading and will finish the whole chapter soon( in a week or so). The last chapter in the book is Inheritance and Polymorphism. That should not take too long to finish. That's the whole book on C++( the brief version). My question is when am I ready to venture out and do something? How much more I need to study? (not to be an expert, that will take years, but just have the minimum tools to venture to something "fun"!)

I want to study Template and Library( in the complete version of Gaddis). But after that, when is enough?
 
  • #51
Several other languages share most of the syntax of C and C++. Those languages include Java and C#, both of which are in my opinion significantly easier to master than C++. As far as I am aware, the only real reason to learn C++ these days is if you want to do Windows or Intel-instruction-set coding "close to the metal" or deep within the operation system. The virtual machine that C# runs on, its very smart compiler, combined with fast hardware these days, will do almost any number crunching that C++ will do, and will do it with less likelihood of a memory leak or a segmentation fault, which are nearly impossible to cause with the newer languages.
 
  • Like
Likes yungman
  • #52
harborsparrow said:
Several other languages share most of the syntax of C and C++. Those languages include Java and C#, both of which are in my opinion significantly easier to master than C++. As far as I am aware, the only real reason to learn C++ these days is if you want to do Windows or Intel-instruction-set coding "close to the metal" or deep within the operation system. The virtual machine that C# runs on, its very smart compiler, combined with fast hardware these days, will do almost any number crunching that C++ will do, and will do it with less likelihood of a memory leak or a segmentation fault, which are nearly impossible to cause with the newer languages.
I am already knee deep in C++, it would be a shame to drop it at this point. My biggest problem with learning C++ is the terms they use, I had a hell of a time following all the names and terms like objects, instance, arguments, instantiation, attributes, methods, dereferencing, streaming...Took me a long time to follow all these. Do other languages use the same terms? If so, that would be a big head start for me. Do other languages follow the same logic like C++, just different syntax?

The other language I would seriously consider is Python.

Thanks
 
  • #53
Those languages are all object oriented and they do use the same words. You will find that learning any 2nd language to be easier than the first. And a third even easier. The libraries will be the main learning curve, and many things including strings and graphics are easier. Python is more different but popular because it is easy to get started in. I like to learn a new language by rewriting some small program whose design and logic I already know. It is a good way to decide what each language is good at.
 
Last edited:
  • Like
Likes yungman
  • #54
harborsparrow said:
Those languages are all object oriented and they do use the same words. You will find that learning any 2nd language to be easier than the first. And a third even easier. The libraries will be the main learning curve, and many things including strings and graphics are easier. Python is more different but popular because it is easy to get started in. I like to learn a new language by rewriting some small program whose design and logic I already know. It is a good way to decide what each language is good at.
Thanks for the info. I am on the chapter of operator overloading in class, one more chapter on Inheritance and Polymorphism and I finish the whole book by Gaddis. What do you think is a good stopping point of C++ and venture out for other things or language? I kind of want to study the chapter on Library and template in his other book, but I am open for suggestions. I hate to start something and stop in the middle. took me a while to decide to take on C++, I want to at least study to a good point to stop. I am kind of regret not choosing Python at the time.

I don't know where to draw the line as I can keep studying C++ forever! Just want to know what is a good place to stop and move on to other things. One thing that bugs me is that I almost finish the whole book and I am still working in cmd window. When am I going to get pass that and actually doing something?

Does Python have pointers, vectors, structures, classes, files etc. like C++ that I can relate to?

Thanks
 

Similar threads

  • Programming and Computer Science
Replies
23
Views
2K
  • Programming and Computer Science
3
Replies
89
Views
4K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
4
Views
1K
Replies
10
Views
2K
  • Programming and Computer Science
Replies
5
Views
6K
Replies
14
Views
1K
  • Programming and Computer Science
Replies
30
Views
4K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
4
Views
620
Back
Top