473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

abstract class question

If I take an abstract class, as shown:

public abstract class PMData
{
public abstract void Save();
}
and then create an inherited class, such as:

public class Property : PMData
{

public override void Save()
{
return;
}
}
In other code, when I instantiate Property, the intellisense in Visual
Studio 2003 allows me to choose between PMData.Save() and Property.Save().
Choosing one or the other doesn't appear to affect the result of the code .
.. . but for some reason, I just didn't think that PMData.Save() would
really be an option when I instantiate Property.

Anyone have any input on this?

-Victor
Nov 15 '05 #1
2 978
I don't understand why intellisense does that either.

Polymorphism determines which class's implementation gets called at runtime.

"Victor Fees" <vf************@seventhfloorinc.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
If I take an abstract class, as shown:

public abstract class PMData
{
public abstract void Save();
}
and then create an inherited class, such as:

public class Property : PMData
{

public override void Save()
{
return;
}
}
In other code, when I instantiate Property, the intellisense in Visual
Studio 2003 allows me to choose between PMData.Save() and Property.Save().
Choosing one or the other doesn't appear to affect the result of the code .. . . but for some reason, I just didn't think that PMData.Save() would
really be an option when I instantiate Property.

Anyone have any input on this?

-Victor

Nov 15 '05 #2
Victor... It does not matter if you call the base class method or the
subclass method, the "proper" method will be called at runtime due to
polymorphism. More explanation at:

http://www.geocities.com/jeff_louie/OOP/oop4.htm

abstract class Drawable
{
*** public abstract String DrawYourself();
}
class Circle : Drawable
{
*** public override String DrawYourself()
*** {
******* return "Circle";
*** }
}
class Square : Drawable
{
*** public override String DrawYourself()
*** {
******* return "Square";
*** }
}

http://www.geocities.com/jeff_louie/OOP/oop9.htm

// an interface version of Drawable
interface IDrawable
{
void DrawYourself();
}
class Circle : IDrawable
{
public void DrawYourself()
{
System.Console.WriteLine("Circle");
}
}

class Square : IDrawable
{
public void DrawYourself()
{
System.Console.WriteLine("Square");
}
}
Regards,
Jeff
In other code, when I instantiate Property, the intellisense in Visual

Studio 2003 allows me to choose between PMData.Save() and
Property.Save().<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Murat Tasan | last post by:
so here is another general question about java... why can't you declare an abstract static method. i can envision the case (indeed i have experienced the case) where one would want an...
17
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products....
10
by: Joe | last post by:
My question is more an OOD question. I know *how* to implement both abstract classes and interfaces. Here's my question - under what circumstacnes does one use an abstract class and under what...
9
by: WithPit | last post by:
I am trying to create an Managed C++ Wrapper around an unmanaged library which contains C++ code. Some of the unmanaged methods returns an returntype which is of the abstract base type (for...
17
by: baibaichen | last post by:
i have written some code to verify how to disable slicing copy according C++ Gotchas item 30 the follow is my class hierarchy, and note that B is abstract class!! class B { public: explicit...
5
by: Tony Johansson | last post by:
Hello!! Assume you have an Interface called ITest with these three method declarations. interface ITest { void foo1(); void foo2(); void foo3(); }
7
by: jason | last post by:
In the microsoft starter kit Time Tracker application, the data access layer code consist of three cs files. DataAccessHelper.cs DataAcess.cs SQLDataAccessLayer.cs DataAcccessHelper appears...
4
by: David Zha0 | last post by:
Hi, "when we call a virtual method, the runtime will check the instance who called the method and then choose the suitable override method, this may causes the performance drop down", is this...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
5
by: Tony Johansson | last post by:
Hello! Here I have an Interface called ITest and a class called MyClass which derive this intrface. As you can see I don't implement this method myTest in class MyClass because i use the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.