Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. abstract classes

abstract classes

Scheduled Pinned Locked Moved C#
question
12 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pankaj Garg
    wrote on last edited by
    #1

    An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

    If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

    C C J J G 8 Replies Last reply
    0
    • P Pankaj Garg

      An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

      If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      As a base class.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      P 1 Reply Last reply
      0
      • P Pankaj Garg

        An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

        If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

        C Offline
        C Offline
        Christian Wikander
        wrote on last edited by
        #3

        Pankaj Garg wrote:

        No funciton definition can be done in these type of classes.

        What do you mean? It's quite possible to have methods and properties in the abstract class. The only limitation is that it cannot be instantiated. As previously stated you use them as base classes that can contain common functionality that all derived classes need/can make use of.

        1 Reply Last reply
        0
        • C Christian Graus

          As a base class.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          P Offline
          P Offline
          Pankaj Garg
          wrote on last edited by
          #4

          This is further to ur reply. If i say , what's the need of such a base class , which doesnot have funciton definition , only contains funciton declaration. I can also create such class , where i am defining the funcitons , further , i can override the base class functions , if needed. Sir , Isn't that ?

          If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

          C 1 Reply Last reply
          0
          • P Pankaj Garg

            This is further to ur reply. If i say , what's the need of such a base class , which doesnot have funciton definition , only contains funciton declaration. I can also create such class , where i am defining the funcitons , further , i can override the base class functions , if needed. Sir , Isn't that ?

            If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            For example, I wrote a paint program. All my paint tools derived from a Tool class. Tool is not useful, it merely defines the base. So, I don't want to be able to create Tool, only it's derived classes.

            Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            1 Reply Last reply
            0
            • P Pankaj Garg

              An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

              If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

              J Offline
              J Offline
              J4amieC
              wrote on last edited by
              #6

              In addition to the answers already given, read up on Polymorphism[^] as it relates to OOP.

              1 Reply Last reply
              0
              • P Pankaj Garg

                An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

                If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                J Offline
                J Offline
                Jorgen Sigvardsson
                wrote on last edited by
                #7

                The abstract keyword is for classes which forms the base for other classes, but does not implement full functionality by itself. You can look at it as a safety net of sorts.

                -- Kein Mitleid Für Die Mehrheit

                P 1 Reply Last reply
                0
                • P Pankaj Garg

                  An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

                  If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #8

                  Pankaj Garg wrote:

                  An abstract class is a special kind of class that cannot be instantiated.

                  Correct.

                  Pankaj Garg wrote:

                  No funciton definition can be done in these type of classes.

                  That is not correct.

                  Despite everything, the person most likely to be fooling you next is yourself.

                  1 Reply Last reply
                  0
                  • P Pankaj Garg

                    An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

                    If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                    C Offline
                    C Offline
                    CPallini
                    wrote on last edited by
                    #9

                    :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                    1 Reply Last reply
                    0
                    • J Jorgen Sigvardsson

                      The abstract keyword is for classes which forms the base for other classes, but does not implement full functionality by itself. You can look at it as a safety net of sorts.

                      -- Kein Mitleid Für Die Mehrheit

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #10

                      Jörgen Sigvardsson wrote:

                      but does not implement full functionality by itself

                      They usually don't, but they may.

                      1 Reply Last reply
                      0
                      • P Pankaj Garg

                        An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

                        If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #11

                        Pankaj Garg wrote:

                        you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                        But if you (for instance, don't take it personally) have a bad idea and tell me about it, and I give you back a better idea, we both end up with one idea. (Both instances of the bad idea get garbage collected.)

                        1 Reply Last reply
                        0
                        • P Pankaj Garg

                          An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes. So what's the advantaghe to incorporate these kind of classes in our project?

                          If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                          H Offline
                          H Offline
                          Hamid Taebi
                          wrote on last edited by
                          #12

                          Yes,thats right you can make a class that its fundamental for other classes but you cant declare variable at this class you can use of it as parent class.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups