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 class constructor?

abstract class constructor?

Scheduled Pinned Locked Moved C#
tutorialquestion
6 Posts 4 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.
  • N Offline
    N Offline
    Niklas Ulvinge
    wrote on last edited by
    #1

    This is what I want to do: abstract class Item { abstract Item(int x, int y) { x = X; y = Y; } } class Transistor : Item { Transistor(int X, int Y) { x = X; y = Y; //some other funcs } } But it wont work. How could I solve it? I got an idea on how to do it... Like this: abstract class Item { abstract Item(int x, int y) { x = X; y = Y; this.init(); } } class Transistor : Item { init(int X, int Y) { //some other funcs } } But isn't there a better way? Niklas Ulvinge aka IDK

    R G E 3 Replies Last reply
    0
    • N Niklas Ulvinge

      This is what I want to do: abstract class Item { abstract Item(int x, int y) { x = X; y = Y; } } class Transistor : Item { Transistor(int X, int Y) { x = X; y = Y; //some other funcs } } But it wont work. How could I solve it? I got an idea on how to do it... Like this: abstract class Item { abstract Item(int x, int y) { x = X; y = Y; this.init(); } } class Transistor : Item { init(int X, int Y) { //some other funcs } } But isn't there a better way? Niklas Ulvinge aka IDK

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      Are you trying something like this? abstract class Item {

      public Item(int x, int y) {
      //...
      }
      }

      class Transistor : Item {
      public Transistor(int x, int y) : base(x, y) {
      //..
      }
      }

      1 Reply Last reply
      0
      • N Niklas Ulvinge

        This is what I want to do: abstract class Item { abstract Item(int x, int y) { x = X; y = Y; } } class Transistor : Item { Transistor(int X, int Y) { x = X; y = Y; //some other funcs } } But it wont work. How could I solve it? I got an idea on how to do it... Like this: abstract class Item { abstract Item(int x, int y) { x = X; y = Y; this.init(); } } class Transistor : Item { init(int X, int Y) { //some other funcs } } But isn't there a better way? Niklas Ulvinge aka IDK

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

        The incomplete code that you show doesn't tell me what it is that you want to do. Can you explain what it is that you are trying to accomplish? --- b { font-weight: normal; }

        N 1 Reply Last reply
        0
        • G Guffa

          The incomplete code that you show doesn't tell me what it is that you want to do. Can you explain what it is that you are trying to accomplish? --- b { font-weight: normal; }

          N Offline
          N Offline
          Niklas Ulvinge
          wrote on last edited by
          #4

          I thought I needed to create an instance of item, wich I didn't have to and couldn't do... I simply removed the construcor and it worked fine. Thanks for your replies. I'm tired and can't think really well now, but now is the only time I can program, (at other times it's only homework, school and more homework). Niklas Ulvinge aka IDK

          1 Reply Last reply
          0
          • N Niklas Ulvinge

            This is what I want to do: abstract class Item { abstract Item(int x, int y) { x = X; y = Y; } } class Transistor : Item { Transistor(int X, int Y) { x = X; y = Y; //some other funcs } } But it wont work. How could I solve it? I got an idea on how to do it... Like this: abstract class Item { abstract Item(int x, int y) { x = X; y = Y; this.init(); } } class Transistor : Item { init(int X, int Y) { //some other funcs } } But isn't there a better way? Niklas Ulvinge aka IDK

            E Offline
            E Offline
            ediazc
            wrote on last edited by
            #5

            best practices of Microsoft recommends the following: abstract class Item { protected Item(int x, int y) { ... } } class Transistor : Item { public Transistor(int x, int y) : base(x,y) { } } Eduardo Diaz site | english blog | spanish blog

            N 1 Reply Last reply
            0
            • E ediazc

              best practices of Microsoft recommends the following: abstract class Item { protected Item(int x, int y) { ... } } class Transistor : Item { public Transistor(int x, int y) : base(x,y) { } } Eduardo Diaz site | english blog | spanish blog

              N Offline
              N Offline
              Niklas Ulvinge
              wrote on last edited by
              #6

              That was what I'm looking for, thanks Niklas Ulvinge aka IDK

              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