Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Misc > Archive::Off Topic

Archive::Off Topic Archive area for Off Topic's posts that were moved here after an inactivity period of 90 days.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-25-2004, 09:25 AM
samandhi's Avatar
samandhi
Demi-God
 
Join Date: Aug 2003
Posts: 1,056
Default A question about C++ programming.

I am trying to learn C++ (from a book, since I dont have the money to take any REAL classes hehe), and have a question that is NOT answered in the book. Probably not a big deal, but I want to know the "why" before Ill totally understand the "how"..
Say I have some code like this:
Code:
 #include <iostream.h>
int Double (int);
int Double (long);
int Double (float);
int Double (double);

int main();
{
  int       myInt = 6500;
  long     myLong = 65000;
  float     myFloat = 6.5F;
  double  myDouble = 6.5e20

  int      doubledInt;
  long    doubledLong;
  float    doubledFloat;
  double doubledDouble;

  cout << "myInt: " << myInt << "\n";
  blah
  blah
  blah

  doubledInt     = Double(myInt);
  doubledLong  = Double (myLong);
  doubledFloat  = Double (myFloat);
  doubleDouble = Double (myDouble);

  cout << "doubledInt: " << doubledInt << "\n";
  blah
  blah
  blah

    return 0;
}
You get THAT idea... Then you have the "Double" functions
Code:
 int Double (int original)
{
  cout << "In Double (int) \n";
  return 2 * original;
}
and the rest is the same exept creating a description/function for each call/prototype from the main function..

Now, while the book says that in this type of polymorphism the function making the call, or the program itself will automatically pick the correct function from the ones listed to do the mathmatical calculations, it doesnt say HOW it knows how to do this. Because I have to tell it how to do everything else (in code which is translated to machine code, or electrical currents if you are going THAT deep), why would I not have to do anything here. Is it something in the compiler itself that is told, that because these are funtions with the same names just different variables, perform a sort-of do while loop? If not, then how does it know....????
__________________

Quote:
Analysis paralysis will keep you from failing, but it will also keep you from succeeding.
  • L.L. CoolJ
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:26 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3