Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 03, 2016, 03:39:53 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: c++ resources for the VB programmer  (Read 4965 times)

Booma-Booma

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
c++ resources for the VB programmer
« on: February 04, 2007, 08:45:00 AM »
Hi all,
I was wondering if any of you could point me to some specific resources about c++ geared towards a VB programmer?

For example, in VB this works as expected:

if x = 6 then....

However in c++:
If (x=6) ....

Doesn't work as I would have expected (coming from a VB background). It took me some time to figure it out. It actually assigns the value of 6 to x. I won't make that mistake again!

In c++ if you declare a variable:

int x;

and then do something like this:
x++;
cout << x;

I get some weird number. I figured that x is being initialized to some random number. Is there any way to have int default initial value = 0?

I am using Dev-c++ for an ide and was wondering how can I set break points so that I can trace through and inspect variable values? I guess what I am getting at is, is there a facility to run programs similar to the way VB does? Or should I just change my mind set?

Cheers,
Troy

Eóin

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
    • View Profile
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #1 on: February 04, 2007, 09:02:34 AM »
I would almost suggest getting a beginners book to C++ and forgetting about what you've learned from VB initially. Once you get past learning the syntax then all your VB knowledge will really stand to you, but initially it could be just confusing because of the subtle differences like those two you've pointed out.

Booma-Booma

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #2 on: February 04, 2007, 10:15:31 AM »
I would almost suggest getting a beginners book to C++ and forgetting about what you've learned from VB initially. Once you get past learning the syntax then all your VB knowledge will really stand to you, but initially it could be just confusing because of the subtle differences like those two you've pointed out.

Eóin, you make a good point! I do have a beginners book on c++ and am reading it. I was just wondering if anybody had heard of specific resources that would help a VB program unlearn bad habits  ;). For the last year or so I was getting into the .net thing. But I am realizing there are far more resources out there for c++ then VB. The other thing that I really like is the potential for cross-platform programing, that would be awesome!

Cheers,
Troy


Eóin

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
    • View Profile
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #3 on: February 04, 2007, 11:06:47 AM »
If you're coming from VB.net then C# could be a wiser option. It's still got the whole ".net thing" but also it is proving to be quite popular so there'd be a lot of resources out there.

That said I'm a C++ programmer myself, and really love the language so I am certainly not discouraging you away from it, but there is no harm in looking into other options :) .

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,405
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #4 on: February 04, 2007, 11:27:24 AM »
I agree with Eoin, not only might c# be a better match, but it's a more modern and "pure" language that will likely teach you better habits  (ironically this advice is again coming from a c++ coder).

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,405
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #5 on: February 04, 2007, 11:29:32 AM »
back to your questions thought:

You can set breakpoints and debug in dev-c++, though its not the best debugging environment.  You could also get Microsoft's free c++ edition.

You've now encountered 2 of the many c++ pitfalls, and survived them, so you are on the right track.
You can initialize variables in c++ when you declare them:
int x=0;

Actually understanding why int variables are not initialized will tell you a bit about the mindset of c++ coders and compiler designers.  C and C++ are designed for speed - so unless you specifically tell the program to set the variable, it's not going to waste precious cpu cycles doing it for you.
« Last Edit: February 04, 2007, 11:32:12 AM by mouser »

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #6 on: February 04, 2007, 12:54:05 PM »
Python Rocks! [attach=#1][/attach]

I'm going to jump in and ask you why you are learning C++? Each language has its own advantages and disadvantages. And depending on what you are coding, some languages may be better suited to the task than others. So, why C++?

Gothi[c]

  • DC Server Admin
  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 858
    • View Profile
    • linkerror
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #7 on: February 04, 2007, 01:02:03 PM »
Maybe because C++ compiles to real binary code instead of running on an interpreter or a vm like python, java, perl, .net, etc,.. etc,... :P

Booma-Booma

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #8 on: February 04, 2007, 01:41:28 PM »
I have looked at c# - It is OK, but I would rather invest my time in learning a language that I can compile to native code and potentially target different operating systems other than windows (I am a big fan of NetBSD). With that said, I can't justify switching from vb.net to a language like c# because it is more popular. From everything that I have read and tried, I can do pretty much everything in vb.net that I could do in c#. So switching doesn't make sense to me.

I have a couple of specific goals in learning c++:
1) I'd like to be able to create dll libraries that I can use from VB6 and .net (etc.) for the times that the engineering calculations are not fast enough in VB6. I have written up some pretty complex Finite Element Analysis models using VB. It worked well but some times it could take a few hours to run through the calculations. I would like to be able to (or at least have the potential) reduce the time it takes.

2)I'd like to be able to access the vast numerical libraries available to c++. 

3)I'd like to create programs that don't need to be registered or require a virtual machine to run.

4)I want to learn something that is worth while learning and will be around for many, many more years.

 

Eóin

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
    • View Profile
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #9 on: February 04, 2007, 01:55:28 PM »
Well 2) and 3) would really clinch it for me too, C++ sounds like the way to go. Good luck, it's a fun language :Thmbsup:

Booma-Booma

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #10 on: February 04, 2007, 01:58:21 PM »
Well 2) and 3) would really clinch it for me too, C++ sounds like the way to go. Good luck, it's a fun language :Thmbsup:

I've been drooling over numerical recipes in c++ for awhile now!

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #11 on: February 04, 2007, 02:26:50 PM »
Booma-Booma,

Those are good reasons. Good luck with your studies. It sounds like you are on the right track.

Ruffnekk

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 332
  • Uhm yeah...
    • View Profile
    • RuffNekk's Crypto Pages
    • Donate to Member
Re: c++ resources for the VB programmer
« Reply #12 on: February 09, 2007, 01:26:43 AM »
It has been said before already, but I want to stress it again: forget everything you know about VB if you want to go to C++. The languages are so different that it's best (and almost a requirement) to start from the absolute beginning. On the other hand, Java could be an option. The syntax will be easier for you and you can also create cross-platform applications.
Regards,
RuffNekk

Programming is an art form that fights back.