x

why should we create absract class and normal class.

hi,I have query when i should use abstract class,what is the use of abstract class over normal class.since Can do same thing with the normal class as well so why i should go for abstrct class,why we create abstact method. eg abstract class ABC { void myfunc() { console.write("hello");

}
abstract void abstfunc();

}
class b: a
{
override void abstfunc(){
console.write("override");}
}
main()
{
class b=new b();
b.abstfunc();
}

the same thing can be done with normal class as well also normal class can be instaintiated.so why we go for abstract class. class ABC { void myfunc() { console.write("hello");

}
void virtual abstfunc(){
}

}
class b: a
{
override void abstfunc(){
console.write("override");}
}
main()
{
class b=new b();
b.abstfunc();
}
same implemented i can do using normal class as well just make a virtual function and overvide it.also having a default function myfunction,also i can make object of it.so why i shall go for abstract class.what are the benefit of abstract class and abstract method. what is the use of this abstract method i can make a virtual function as well.
more ▼

asked Aug 11, 2012 at 03:00 PM in Default

abcd123 gravatar image

abcd123
10 2 2 2

It looks like you have struck lucky and got an answer to your question but this forum is generally focussed on SQL Server and Oracle problems. You may find more responses to your problems if you search for a bespoke C# forum.
Aug 12, 2012 at 02:05 PM Fatherjack ♦♦
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first
You would want to use abstract when you don't intend for the user to instantiate the class because it is too general and simply serves to define common members for sub-classes. Abstract members cannot contain default implementation code and must be overridden, virtual members may contain default implementation code.
more ▼

answered Aug 11, 2012 at 04:32 PM

Scot Hauder gravatar image

Scot Hauder
6k 13 15 18

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x21

asked: Aug 11, 2012 at 03:00 PM

Seen: 596 times

Last Updated: Aug 12, 2012 at 02:05 PM