Hello,
i have do do an exercise,
but i have always an error like"marked as override cannot be marked as new or virtual"
my program is: - public class Shape
-
-
{
-
protected Point p;
-
public Point my_p
-
{get; set;}
-
public Shape (){}
-
public Shape(Point p) { this.p = new Point(p.my_x, p.my_y); }
-
public virtual void Show() { p.Show(); }
-
}
-
-
-
public class Segment :Shape
-
{
-
-
protected int a;
-
-
public int my_a { get; set; }
-
public Segment() :base(new Point(0,0))
-
{this.a = 0; }
-
-
public Segment(Point p, int a):base(p)
-
{ this.a = a; }
-
public override void Show()
-
{
-
Console.WriteLine("Segment Point ");
-
p.Show();
-
Console.WriteLine("Length ",a);
-
-
}
-
}
-
-
-
-
public class RealPoint : Segment
-
{
-
-
-
public RealPoint(Point p)
-
: base(p, 0) {}
-
public override void Show()
-
{ Console.WriteLine("RealPoint Point "); p.Show();}
-
-
}
-
-
-
-
-
using System;
-
public class Point
-
{
-
public int x;
-
public int y;
-
public Point() { x = 0; y = 0; }
-
public Point(int x,int y) { this.x = x; this.y = y; }
-
public Point(Point p) { this.x = p.my_x; this.y = p.my_y; }
-
-
public int my_x { get { return x; } set { x = value; } }
-
public int my_y { get { return y; } set { y = value; } }
-
public static Point operator +(Point p1, Point p2)
-
{
-
Point ret = new Point(p1.x + p2.x, p1.y + p2.y);
-
return ret;
-
}
-
public static Point operator -(Point p1, Point p2)
-
{
-
Point ret = new Point(p1.x - p2.x, p1.y - p2.y);
-
return ret;
-
-
}
-
public static Point operator +(Point p1, Size s)
-
{
-
Point ret = new Point( p1.x + (int)s.my_x,p1.y + (int)s.my_y);
-
-
-
return ret;
-
-
}
-
-
public void Show(){
-
-
Console.WriteLine("(",x,",",y,")");
-
-
}
-
-
}
-
-
-
-
-
public class Size
-
{
-
public uint x;
-
public uint y;
-
public Size() { x = 0; y = 0; }
-
public Size(uint x,uint y) {this.x = x; this.y = y; }
-
public uint my_x { get { return x; } set { if (value >= 0) x = value; } }
-
public uint my_y { get { return y; } set { if (value >= 0) y = value; } }
-
public static Size operator +(Size s, Point p1)
-
{
-
Size ret = new Size();
-
return ret;
-
-
}
-
-
public void Show()
-
{
-
-
Console.WriteLine("(", x, ",", y, ")");
-
-
}
-
}
I have blue marks in the show function with the above error (marked as override cannot be marked as new or virtual)
thank for asnwer
0 1104 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Adrian Herscu |
last post by:
Hi all,
In which circumstances it is appropriate to declare methods as non-virtual?
Thanx,
Adrian.
|
by: Eric Johannsen |
last post by:
I have a simple object that inherits from CollectionBase and overrides the
Count property:
namespace MyTest
{
public class CollTest : System.Collections.CollectionBase
{
public override int...
|
by: Ken Varn |
last post by:
Is there anyway to override a public virtual method or property so that it
is private in my derived class?
I tried using new on the property and making it private, but no luck.
--...
|
by: A.Bekiaris |
last post by:
Hi
I have an abstract class with some virtual methods which I inherit and create say Class1 I want to give end users the ability to override the virtual methods of the base class
How this can...
|
by: Stephane |
last post by:
Hi,
I'm trying to create a virtual directory dynamically in my web site using
ASP.NET. I received this error:
System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a
file...
|
by: moleskyca1 |
last post by:
What operators cannot be virtual and why? I looked at FAQ and found
nothing.
I think there are operators that cannot be virtual, but I don't know
why?
|
by: bullibabu |
last post by:
Dear members,
I have a question. why the constructor cannot be virtual and friend?
Could someone clarify me with explanation.
Thanks
Srinivas
|
by: muler |
last post by:
"If an instance method declaration includes the sealed modifier, it
must also include the override modifier." The C# Programming Language,
§ 10.5.5 Sealed Methods
Why is this?
Thanks,...
|
by: rajeev2007 |
last post by:
why we cannot create virtual constructor.
|
by: puzzlecracker |
last post by:
The statement is taken from FAQ . What about non-virtual
functions? Can they be overriden? I still don't see a good
justification to prefer private inheritance over composition. In
fact, I have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
| |