473,387 Members | 1,844 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,387 software developers and data experts.

C# classes quesitons

1. Can an abstract class have some implementation (say default
assuming derived chooses not to implement it)?

2. Does CSharp has a concept of inner class comparable to java's,
where inner class can reference into wrapping class?

3. How is virtual, and polymorphism in general, is implemented?
Thanks

Sep 30 '08 #1
3 1180
On Sep 30, 8:13*am, puzzlecracker <ironsel2...@gmail.comwrote:
1. Can an abstract class have some implementation (say default
assuming derived chooses not to implement it)?

2. Does CSharp has a concept of inner class comparable to java's,
where inner class can reference into wrapping class?

3. How is virtual, and polymorphism in general, *is implemented?

Thanks
1. Can an abstract class have some implementation (say default
assuming derived chooses not to implement it)?
Abstract class can have implementation for some of the methods. If a
class that is derived from an abstract class, chooses not to override
the abstract method, the class should be abstract again.
2. Does CSharp has a concept of inner class comparable to java's,
where inner class can reference into wrapping class?
If you mean class declared with in another class, Yes, it is
supported.
3. How is virtual, and polymorphism in general, is implemented?
it is implemented with the virtual and override keywords.

http://www.vijaymukhi.com/documents/...sics/chap9.htm
http://www.devhood.com/tutorials/tut...utorial_id=374

explains the ovverride concept in C#

-Cnu


Sep 30 '08 #2
On Mon, 29 Sep 2008 20:13:47 -0700, puzzlecracker <ir*********@gmail.com>
wrote:
1. Can an abstract class have some implementation (say default
assuming derived chooses not to implement it)?
Yes. Though, given your previous question a week ago ("If we implement
methods in abstract class, do we still need to
declare them as abstract"), I have no idea why you don't already know the
answer to this one.
2. Does CSharp has a concept of inner class comparable to java's,
where inner class can reference into wrapping class?
No. You can have nested classes in C#, but they are related only with
respect to accessibility of the outer class members. There's no implicit
reference to any specific instance of the outer class (i.e. they are like
Java's static nested classes).
3. How is virtual, and polymorphism in general, is implemented?
Define "implemented". Are you asking what the actual underlying
implementation is when you use virtual methods or interfaces? If so, the
basic answer is that it's similar to how C++ does it, with a v-table.

Pete
Sep 30 '08 #3
Hi puzzlecracker,
1. Can an abstract class have some implementation (say default assuming
derived chooses not to implement it)?
the best way to remember the difference is first of all it's a class, and
only then it's abstract. So, as a class it has implementation, but, because
it's abstract it cannot be instantiated.

Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com
1. Can an abstract class have some implementation (say default
assuming derived chooses not to implement it)?

2. Does CSharp has a concept of inner class comparable to java's,
where inner class can reference into wrapping class?

3. How is virtual, and polymorphism in general, is implemented?

Thanks

Sep 30 '08 #4

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

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
9
by: Jack | last post by:
Hello I have a library of calculationally intensive classes that is used both by a GUI based authoring application and by a simpler non-interactive rendering application. Both of these...
9
by: Aguilar, James | last post by:
I know that one can define an essentially unlimited number of classes in a file. And one can declare just as many in a header file. However, the question I have is, should I? Suppose that, to...
12
by: Langy | last post by:
Hello I'm fairly new to C++ but have programmed several other languages and found most of c++ fairly easy (so far!). I've come to a tutorial on classes, could someone please tell me why you...
4
by: john townsley | last post by:
do people prefer to design classes for the particular job or for a rangle of tasks they might encounter now and in the future. i am doing some simple win32 apps and picking classes is simple, but...
2
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how...
18
by: Edward Diener | last post by:
Is the packing alignment of __nogc classes stored as part of the assembly ? I think it must as the compiler, when referencing the assembly, could not know how the original data is packed otherwise....
6
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
0
by: ivan.leben | last post by:
I am writing this in a new thread to alert that I found a solution to the problem mentioned here: http://groups.google.com/group/comp.lang.c++/browse_thread/thread/7970afaa089fd5b8 and to avoid...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.