|
How do you then distinguish between instances and derived classes? My idea is that a class is a "template" and instances of the class are the "live" entities. Going by that logic, a specific car (say a Benz) is an instance of type car. I'd consider AutomaticTransmissionCar and ManualTransmissionCar to be subclasses of Car, for example.
What do you say?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Consider the following hierarchy:
-----------Vehicle -----------
/ | \
Car Boat Aircraft
/ \ / \ / \
Truck Van Sailboat Yacht Helicopter Blimp Note that Yacht is derived from Boat , which is derived from Vehicle , but there are no instances of any of the classes until one is defined. You define an instance like:
Helicopter whirlybird; Here whirlybird is an instance of the Helicopter class.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Yeah, but Yacht is not related to Boat in the same way as Benz is to Car. You can have several models of Yachts which have exactly the same properties but different values for them. But a Yacht is a specific kind of Boat with other properties.
Likewise, a Benz and a Corolla have the properties of a car but have different values.
DavidCrow wrote:
Here whirlybird is an instance of the Helicopter class.
I thought that's what I said too (I'm assuming whirlybird is a helicopter model).
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
"Derived from" and "instance of" are mutually exclusive terms. By definition, an instance of class is the actual occurrence of that class.
In your example, Benz is not derived from anything. It is an instance of the Car class.
S. Senthil Kumar wrote:
I thought that's what I said too
You said something about an instance being a live entity, whatever that is.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
You said "Sure it is. A Yacht is a Boat, and a Benz is a Car, and they are all Vehicles. However, until one of those objects actually exist, there are no instances".
Going by that logic, why not derive whirlybird from Helicopter? whirlybird is a helicopter, after all. Then DavidCrow, SenthilKumar, instead of being instances of Humans, would be subclasses of Humans...
DavidCrow wrote:
By definition, an instance of class is the actual occurrence of that class.
I agree and that's why I don't think Benz should be derived from Car.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
bhangie wrote:
Below is the code i have written, is there something wrong
Provide A Default Constructor to your class, like this
class Animal
{
public:
Animal();
Animal(const string &name, const char &sex, const string &Colour, int age);
~Animal();
---- SNip----------
}
Animal::Animal()
{
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Thank's for the help oaks.
Bhangie
Education begins a gentleman,
conversation completes him
|
|
|
|
|
Hi every one!
I m trying to build a project in Visual C++ using Microsoft Visual C++ 6.0 compiler. when i built a project file, this error occurred:
"This program cannot be run in DOS mode.
Error executing c:\windows\system32\cmd.exe"
some one kindly tell me y this error occurred & wts the remedy to it?
Regards
Usman Arif
Usman Arif
|
|
|
|
|
Hi,
Could someone advise me how to spy at a com port when
another existing running application is using the same com port for serial communication? Preferably with sample coding.
My intention is to build a serial port monitor
Because, it would complain error...com port in use, then my spy program will exit.
I use CreateFile Function.
thanks, Sally
|
|
|
|
|
|
Thanks, Joel.
But I have to write my own program, though I know there are already commercial products available. This is one of my work assignments.
Sally
|
|
|
|
|
hey boss,
u got to write a upper filter serial driver above the existing functional driver. refer to filter drivers in DDK.
Regards,
Adi
|
|
|
|
|
Hi guys
Im working on a program that factorises a large number into two primes. I am experiencing some problems. Im not going to explain all my code here, but in short C++ makes wrong calculations. I think it has something to do with the capacity of the variables (int, unsigned long etc). For example, it tells me that 131221*229123 = 978111.
Why is this? Ive been experiencing with various data types, but I still get these "wrong" calculations. Can anyone tell me what I should do to make this work? Remember I am working with large numbers (up to six digits).
I really appreciate the help.
|
|
|
|
|
The max value for an int = ~2.15 billion
131221*229123 = ~30 billion
Try using an __int64 variable:
Date Type Ranges
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
as Jack Squirrel said, you can do this in the calculator of your choice :
2^32 -> 4294967296 (maz value of an unsigned long)
131221*229123 -> 30065749183 (out of range...)
if you like to use an integer absolutely, use __int64. otherwize, double or long double are good enough...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
131221*229123 = 30065749183 but you get 978111.
Basically your number is truncated. Look at the hex representation.
30065749183 = 0x7000EECBF
978111 = 0x0000EECBF
Use __int64.
|
|
|
|
|
Does anyone have any suggestion on what software I should purchase to start programming in C. I am a beginner. Found that I love to write code and create things. any suggestions would be helpful. Thanks
|
|
|
|
|
Are you hoping to use C, C++ or C# ? C is a bit outdated these days, and would certainly have a steep learning curve. The C++ curve is not insurmountable, but C# would be easier. There are free options for all of these languages, but if you can get your hands on a copy of Visual Studio, for example if you're a student and can buy one at the educational price, it would be well worth your while. The help a good IDE gives you makes learning a whole lot easier. I shudder when I think of the terrible IDE's I used when I was learning, because I got them cheap ( not to imply that Microsoft are the only people to do a good IDE, but VS is excellent, the price is right if you can get education pricing, and it means you have a number of languages at your disposal out of the box ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
You can download VS 2005 beta. It's free, and a very good tool for programming in C, C++ and C# (if you want to program in these languages).
I also got the blogging virus..[^]
|
|
|
|
|
it looks like C# is the way to go by both replies. I'll have to check on prices. I'm hoping it won't be to bad.
Thank you for the help.
|
|
|
|
|
Any body knows how to find out if the harddrive is fragmented via C++ or WMI script?
thanks in advanced.
|
|
|
|
|
|
Hi
I have a project that is dependent on some of the laiter windows platforms for some of it's functionallity so the question is is there a way of determinig the OS running.
and
how many different windows platforms are there.
can anyone help me.
G_S
|
|
|
|
|
G_S wrote:
how many different windows platforms are there.
Lots.
I'm serious - if you factor in all the various versions of IE, the service packs, the Win9x and WinNT lines, it's a frighteningly large number.
Generally, if you wish to use an API that only exists in certain versions, you're best finding a way to include the redistributable for that API along with your install. Failing that, test for the existence of the API prior to using it (for regular APIs, that usually means LoadLibrary() + GetProcAddress() rather than static linking).
For other platform-dependant functionality (such as registry locations, file formats), you're gonna have to either get more creative, or write for the lowest common denominator.
You must be careful in the forest
Broken glass and rusty nails
If you're to bring back something for us
I have bullets for sale...
|
|
|
|
|
Thanx
It's Actually only the API and specifically the tool help functions.
I was really hopping for something nicer to read.
so this leaves me with no way around the LoadLibrary ,GetProcAddress ..
Thank you anyway
G_S
|
|
|
|