C++

nightwolf41

Newbie
Joined
Nov 19, 2004
Messages
51
Reaction score
0
Hey this is a pritty easy question that I would like to know that answer to,

Does Visual Basic use C++ coding?

If anyone could tell me the answer to this it would be very helpful
 
Ti133700N said:
Visual Basic uses Visual Basic coding.

Ouch! that was very "to the point".

Visual Basic does use its own language, but it is highly recommended by all the tuts i've seen, that you begin with another language, ie C++ before moving on to Visual Basic. DONOT however, begin with QBASIC, as I did... it really disadvantages you...
 
Start with C++ or Java. Then learn all the cute other languages that are good for one thing.
 
Toddpants said:
Start with C++ or Java. Then learn all the cute other languages that are good for one thing.

Actually most people start with C then move to the object oriented programming languages like Java and C++.
 
As Dijkstra says,

"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
 
yeh it's just, we are using VB at school and i wanted to know if C++ Would help me with VB or just completly confuse me!
 
Ranga said:
Visual Basic does use its own language, but it is highly recommended by all the tuts i've seen, that you begin with another language, ie C++ before moving on to Visual Basic.

Eh? Starting with C++ and then "move on" to Visual Basic?

That's like, say, learning on a Ferrari to drive a Volkswagen Bug ;)
 
You could start with C or BASIC... but C is an old and dying standard; a holdover from the olden days of programming. BASIC has really lax methodology which will likely get a programmer into trouble with learning other, more popular languages.

Start on C++. It's heavy handed and very logical (painfully so at times) but it is POWERFUL. C# and JAVA were built upon the C++ example (Object Oriented) and while some say that C++ isnt the purest implementation of object oriented programming, it IS a very powerful language.

By the by, Visual BASIC .Net can be used to program game engines... 3d style. There are books on it.
 
I had exposion to BASIC but I was in the sixth grade and thankfully never really got into it.

Though i did get into php\javascript(Obviously html) which does help me understand switch\if\loops...things like that.
I'm only starting C++, but I already love it.

I do have a small question.
I have int main() obviously... and another function. Can I change a variable in main from another function? I've tried various diffrent things but hasn't worked.
 
You can pass variables to the function by Reference (So they're not copied as normal, but the *original* gets changed inside the function).

Normal:

Code:
void myFunc(int myVar)
{
  blah...
}

Here, changing myVar in the function does *not* change the myVar in the calling routine (eg, main).

Code:
void myFunc(int & myVar)
{
  blah...
}

Here, myVar is passed by reference to the function; Changing myVar in it also changes it in main (or whatever function you called myFunc from).


Another method, a bit more difficult but IMO better (and more multi-purpos'ish) are POINTERS ;)

Pointers can be *very* powerful, but also *very* confusing (you can create lots of "nice" errors and bugs with pointers).

I suggest reading some pointer-tutorials... but here's the basics:

Code:
int myVar;
int * myPointer;

// normal value assignment
myVar = 5;

// The & operator returns the ADRESS of the variable; Now, "myPointer" points to "myVar".
myPointer = &myVar;

// the * operator DEREFERENCES the pointer. That means, *myPointer is the VALUE of the ADRESS myPointer POINTS to (duh...). Writing only myPointer is the ADRESS only, not the value. Clear so far? ;)
*myPointer  = 7;

Now, the magic begins ;) By passing a pointer to a function, the function now "knows" where the variable the pointer points to stands in memory, thus can change its value. The pointer itself is passed normal (by value) to the function, not by reference; It doesn't matter it only gets handed as a copy to the function, because it hasn't to be changed (except if you want to change the pointer ITSELF in the function... speak about double-pointers, pointers to pointers then ;) **myDoublePointer... but that's going a bit too far by now!)

Thus:

Code:
void myFunc(int * myVar)
{
   *myVar++;
}

int main()
{
   int bleh = 5;

   myFunc(&bleh);

   cout << bleh << endl;

   return 1;
}

Can you see what's going on? We pass the ADRESS of bleh to the function, and in the func, the DEREFERENCED pointer *myVar gets increased with ++, thus changing the VALUE of bleh.


Got it? ;)
 
Back
Top