have a problem with inheritance

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 63
Reputation: polo_coins is an unknown quantity at this point 
Solved Threads: 0
polo_coins polo_coins is offline Offline
Junior Poster in Training

have a problem with inheritance

 
0
  #1
Oct 19th, 2008
I built two different classes and I want that one class get inherit from another ,
but when I build Constructions Compiler throw me an Error.
I get to conclusion that i must use base function
so I build Constructor like this one :
public name_class:base()
my question what do I put between parentheses and if my syntax o.k and what is the right way to built such constructor

Thanks, sergey
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1,602
Reputation: scru has a spectacular aura about scru has a spectacular aura about 
Solved Threads: 130
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Virtuoso

Re: have a problem with inheritance

 
0
  #2
Oct 19th, 2008
Have you tried:

  1. public class Child : Parent
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 63
Reputation: polo_coins is an unknown quantity at this point 
Solved Threads: 0
polo_coins polo_coins is offline Offline
Junior Poster in Training

Re: have a problem with inheritance

 
0
  #3
Oct 19th, 2008
Originally Posted by scru View Post
Have you tried:

  1. public class Child : Parent
It's O.K. this thing I understand I mean syntax of building Constructors and call for Metgods of parents, I tried a couple things and here what I got :
public Name_of Chuld (type_of_variable name_of_it):base(name_of_this_variable_in_Parent)

and when I call for parent function :
base.Name_ofParentFunction();

are the other way of doing so, and how it will look like for calling Parent function that get's some variables from Main for example ?

Thanks Sergey
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: have a problem with inheritance

 
0
  #4
Oct 19th, 2008
OK but if you had

  1. class MyClass
  2. {
  3. private int myval =0;
  4. public MyClass (int value)
  5. {
  6. myval=value;
  7. }
  8.  
  9.  
  10. public int MyValue
  11. {
  12. return myval;
  13. }
  14. }

You would call this in your inherited with

  1. public MyNewClass : MyClass
  2. {
  3.  
  4. public int MyNewValue : base MyValue(1)
  5. {
  6.  
  7. }
  8.  
  9. }
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 63
Reputation: polo_coins is an unknown quantity at this point 
Solved Threads: 0
polo_coins polo_coins is offline Offline
Junior Poster in Training

Re: have a problem with inheritance

 
0
  #5
Oct 20th, 2008
Thank LizR
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC