Hello All

I have two classes
1. Employee
2. Project

both classes have a create function

create function of Employee class creates a new Employee
it takes object of Employee class as input parameter and return bool

create function of Project class creates a new Project
it takes object of Project class as input parameter and return bool

Now I want to create a abstract class which will contain a create function
So I can inherit that abstract class into my both above classes

What should be the prototype or signature for that create function of abstract class
Which should be able to take any type of class object?

Any help ???

Thanks in advance

Recommended Answers

All 3 Replies

public abstract class AbsClass
    {
        public abstract void Create();
    }

    public class Employee : AbsClass
    {
        public override void Create()
        {
            throw new NotImplementedException();
        }
    }

    public class Project : AbsClass
    {
        public override void Create()
        {
            throw new NotImplementedException();
        }
    }

Hello RamyMahrous,

first thanks for response

when i will call create function for employee or project ,i will pass a object of that type ,so this function should able to take object of both classes,
but above prototype didn't have any input parameter ,so which type of input parameter it should take

thanks

It should take parameter of type AbsClass

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.