What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » [split] C++ and VB debate

[split] C++ and VB debate
Author: Message:
TheAvenger
New Member
*


Posts: 9
Joined: Jun 2003
O.P. RE: RE: Random number generator?
quote:
Originally posted by NoName
Its all over google in any language :-/

code:
In Form_Load()
Randomize
End Sub

Public Function Rand(ByVal Low As Long, _
                     ByVal High As Long) As Long
  Rand = Int((High - Low + 1) * Rnd) + Low
End Function


(Visual Basics)

code:
include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    int random_integer = rand();
    cout << random_integer << endl;
}

   random_integer = (rand()%10);

(C++)


Notice the VB one makes sense while the C++ one just seems like a bunch of random jabber :p


as a c++ programmer. I'll have to disagree with you here.  The c++ seems perfectly logical and straight forward.  How come you need to have some weird form_load function just to say randomize? And what is ByVal supposed to represent? int? string?... maybe bool? And where does it print the result? Does it print the result? And you actually have to DECLARE the end of the function? What a } isn't easy enough?
09-06-2004 02:00 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Random number generator?
quote:
Originally posted by TheAvenger
The c++ seems perfectly logical and straight forward.
Not for someone who doesn't know C++... The VB one looks far more "logical" then the C++ for the inexperienced person... (and that is almost a fact; the advantage of VB above C++ is that its code is far more easy to understand then C++)

Everybody without programming experience will understand
  Rand = Int((High - Low + 1) * Rnd) + Low
faster and easier then:
  int random_integer = rand()
  cout << random_integer << endl
  random_integer = (rand()%10)

And it seems more logical then the C++ one (although both are equaly logical) ... And that's exactly what NoName meant....

quote:
Originally posted by TheAvenger
How come you need to have some weird form_load function just to say randomize?
You don't need that at all. It is just were NoName has put the code... Something which anybody who has a very small notion of VB knows. I can backfire this: "Why do you need some weird main() routine in C++??"

quote:
Originally posted by TheAvenger
And what is ByVal supposed to represent? int? string?... maybe bool?
ByVal Low As Long
ByVal means reference by value, not by name... This means when the variable "Low" is changed (Low = 5) the referenced variable isn't updated with the new value... And because of this, in the current function it isn't needed at all, since "Low" or "High" isn't updated anyways... (you should know that as you are a programmer like you said yourself :undecided:)

quote:
Originally posted by TheAvenger
And where does it print the result?
The VB one is a function... Again, anybody who has a very small notion of VB knows that that will return the number. I can even backfire this: "Where does it print the result in the C++ code???" Your response will be just the same as mine: NoName showed only the important calculation code...

quote:
Originally posted by TheAvenger
And you actually have to DECLARE the end of the function? What a } isn't easy enough?
1) there isn't anything to declare....
2) VB doesn't use "{...}". It uses "Function... End Function", just like "If... Then... Else.... End If".....
This is a very very very basic difference between VB and C++ which almost everybody knows.... It is called a programming syntax.... I can backfire this to you: "Why do you end each line in C++ with ';'... it seems so useless, C++ isn't smart enough to reconize the end of a line or what????"

I can't believe you don't know about that as you are a C++ programmer like you said, and C++ programmers are often more experienced in programming :undecided: It's just the same as comparing French to English....




Furthermore, don't dish VB like that, and don't start a "VB vs. C++"-war. It's not only useless, it's even stupid, as both languages have their OWN set of codes and programming syntax. And both languages have their OWN uses and functionality....

PS: I'm not saying VB is better then C++... I'm just replying to your post, and in this case definding VB as you posted questions which cleary shows that you are either biased towards VB and/or don't know it at all...

This post was edited on 09-06-2004 at 02:44 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-06-2004 02:32 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On