Qbasicnews.com

Full Version: C/C++ ??
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
function overloading == polymorphism?
If so, read on...

Code:
void meh(int myvar);
void meh(char myvar);
void meh(int myvar1, char myvar2);

This is the declaration of two functions, but note that they have
the same name. So, when you call the function[s] the function[s] is
executed that has the appropriate argument(s)

Note: I have not checked the above code and I'm a lousy C++ coder...
No, I know what function overloading is. Tongue
Just what's the use of it?
Quote:actoully, C do have function overloading, the C99 standard alowes it.

Can you post a link to back that up? I can't find any thing on C99 allowing function overloading, heres a list of the features that are in C99: http://gcc.gnu.org/c99status.html.

Quote:No, I know what function overloading is.
Just what's the use of it?
Its quite useful in OO languages, where a method in a class could intuitively be called with different arguments. For example:
Code:
public class Player {
  private String lastName, firstName;

  /* SetName for players with only a first name */
  void setName(String name) {
    firstName = name;
  }

  /* SetName for players with a first and last name */
  void setName(String fName, String lName) {
    firstName = fName;
    lastName = lName;
  }

  /* Return the players name */
  String getName() {
    return firstName + " " + lastName;
  }
}
Oh, come on, talk about laaazy.
Code:
void whatever(int um,int blarg)
{
if (blarg==NULL)
    /* blarg argument not supplied */
else
   /* both args supplied /*
}
It's not technically "not supplied" but seriously, set a value to signify that the player doesn't have a last name. Tongue
Can't we all agree that QBasic is way better then C/C++ or Java?
QB is an easy language. Smile
Take a look at what it stands for. It's all true, minus the "Quick" part. Tongue
Beginner's All-Purpose Symbolic Instruction Code.
Quote:Can't we all agree that QBasic is way better then C/C++ or Java?
Nope. You cant really compare them anymore now, Qbasic was fun, but its different, and too old to compete against the latest compilers. Besides personally, i like C.


Anyways one point: If c++ is c with classes, then java is classes without c. Really, theres more to c++ then just classes.(namespaces,templates) and althouth you could argue the forced casting is a pain, it does help hide some hard to find bugs.
Isn't C older then BASIC?
Yes, I believe so...Bell Labs made B in the 70s, and then they wanted a new language...guess what it was called? :lol:
Not the language, the compilers. C compilers are constantly updated and released, qbasic is and will remain the same. You never stated basic, you said "qbasic", which is itslelf a Basic compiler. and basic was in the 60's so no.(although it looked very different at the time)

Also c is constantly modified, the latest version C99 is practicly brand new.
Pages: 1 2 3 4 5 6 7 8 9