CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    G day Mayt Land
    Posts
    971

    Inheterence issue

    /Error CS0534: 'AverageSummary' does not implement inherited abstract member 'SummaryStrategy.PrintSummary()' (CS0534) (Tk1)

    I am not sure what the problem is and what it is that I am not doing


    ===============================
    Code:
    base class :
    
    using System;
    using System.Drawing;
    
    namespace Tk1
    {
        public abstract class SummaryStrategy
        {
         
    
            public abstract void PrintSummary();
    
    
        }
    }
    THE CHILD CLASS
    Code:
    using System;
    namespace Tk1
    {
        public class AverageSummary:SummaryStrategy
        {
           
            private List<int> _asnumbers = new List<int>();
            public float Average;
    
            public AverageSummary(List<int> numbers)
            {
    
                Console.WriteLine("I am in AverageSummary");
                double sum = 0;
    
                foreach (var element in numbers)
                {
                    sum += (double)element;
                    _asnumbers.Add(element);
                }
    
                var avg = sum / numbers.Count();
                Average = (float)avg;
                //PrintAverage(numbers);
            }
           public void PrintAverage()//(List<int> numbers)
           {
            }
        }
    }
    THANK you
    Using Java version on windows 1.8_51

  2. #2
    Join Date
    Feb 2017
    Posts
    675

    Re: Inheterence issue

    Quote Originally Posted by Saeed View Post
    /Error CS0534: 'AverageSummary' does not implement inherited abstract member 'SummaryStrategy.PrintSummary()' (CS0534) (Tk1)

    I am not sure what the problem is and what it is that I am not doing
    You inherit the SummaryStrategy class into AverageSummary. It means AverageSummary is_a SummaryStrategy. But to be that, AverageSummary must implement all abstract methods of SummaryStrategy. Does it do that? No, It does not implement the PrintSummary() method. That is what the error message tells you.
    Last edited by wolle; October 5th, 2022 at 01:06 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured