Basic Programming Questions
How do I manage inheritance in C++? I''m pretty proficient at programming in Java, so I understand the concepts, but I don''t understand the syntax.
It''s something like:
class One
{
...
}
Class Two::One
{
...
}
Is that correct for making Two extend One?
Also, I''ve noticed people set variables to values such as 1.0f. What''s the significance of the "f"?
Tolerance is a drug. Sycophancy is a disease.
//.h
class Base_Interface
{
//virtual destructor is important for OOP
virtual ~Base_Interface(){}
//Pure abstract methods
virtual Method1()=0;
};
class Derived : Base_Interface
{
virtual Method1();
};
//.cpp
Derived::Method1()
{
//do_something();
}
Magmai Kai Holmlor
"Oh, like you''ve never written buggy code" - Lee
[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ]
[Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)]
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
class One
{
};
class Two: public One
{
};
The 'f' signfies "float", which has a lower precision than double. It's a real number. Any real number is usually interpreted as a double, so if you've got functions accepting floats then you need to bung that 'f' in there, ugly as it is.
EDIT: Whoops! First class thing was in Java
[edited by - Alimonster on July 22, 2002 7:31:15 PM]
{
};
class Two: public One
{
};
The 'f' signfies "float", which has a lower precision than double. It's a real number. Any real number is usually interpreted as a double, so if you've got functions accepting floats then you need to bung that 'f' in there, ugly as it is.
EDIT: Whoops! First class thing was in Java
[edited by - Alimonster on July 22, 2002 7:31:15 PM]
quote: Original post by fisheyel83l
How do I manage inheritance in C++? I'm pretty proficient at programming in Java, so I understand the concepts, but I don't understand the syntax.
It's something like:
class One
{
...
}
Class Two::One
{
...
}
Is that correct for making Two extend One?
Also, I've noticed people set variables to values such as 1.0f. What's the significance of the "f"?
For you Java programmers :
#define extends : public// this comment here just to preserve formatting in this source boxclass One{};class Two extends One{};
[edited by - fallenang3l on July 22, 2002 8:55:39 PM]
lol fallenang3l... I got yelled at when I suggested to some former VB person:
:-)
-SniperBoB-
[edited by - snprbob86 on July 22, 2002 9:05:36 PM]
[edited by - snprbob86 on July 22, 2002 9:05:53 PM]
#define and &&#define or ||
:-)
-SniperBoB-
[edited by - snprbob86 on July 22, 2002 9:05:36 PM]
[edited by - snprbob86 on July 22, 2002 9:05:53 PM]
Brandon Bloomhttp://brandonbloom.name
quote:
Also, I''ve noticed people set variables to values such as 1.0f. What''s the significance of the "f"?
It means float, as opposed to double (float), which is the default.
Magmai Kai Holmlor
"Oh, like you''ve never written buggy code" - Lee
[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ]
[Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)]
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement