[Solved] please clear – To achieve runtime polymorphism in c# we use Interface? [closed]

You don’t have to define seperate interfaces for this. You can also use a baseclass to achieve polymorphism. For more info check this page: Polymorphism – C# programming Example of using polymorphism in C#: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Animals { class Program { static void Main(string[] args) { … Read more

[Solved] Hello!!!. So in a quiz que were given the following classes and we were asked to give the output. [closed]

The two additional setting are printed by B‘s constructor. B‘s constructor calls A‘s constructor which then calls B‘s overridden SetNumber Function which prints setting. B‘s constructor is called twice and SetNumber is called directly twice leading to four Settings. solved Hello!!!. So in a quiz que were given the following classes and we were asked … Read more

[Solved] C++ How to make a vector with a class type pointer

It seems that you want to change the database type, from: std::vector <Employee> *EmployeeDB; this is a pointer to a vector, holding Employee instances. This means that the vector contains copies of employees, probably not what you want. To: std::vector <Employee*> EmployeeDB; This is a vector instance, holding pointers to Employees. You also should take … Read more

[Solved] How to create a static variable shared amongst instances of closed constructed generic types?

There’s 3 ways that I can think of that would work for you: Create a non-generic base class holding the shared field(s) Create a non-generic separate class holding the shared field(s) Create a non-generic type that holds these shared values, and reuse this inside your generic ones For the third one, since you say you … Read more

[Solved] Not able to print value of an array while using inheritance in C# [duplicate]

Your PrintDetails() method is printing the array without any kind of formatting (hence it’s just printing the array type) use string.Join to print the array delimenated by commas public override void PrintDetails() { Console.WriteLine(“Hi my name is ” + _name + ” and I am studying ” + string.Join(“,”, _subjects)); } ought to do it. … Read more

[Solved] How do I correctly implement this code segment without getting a logic error? [closed]

Shoe roshe = new Nike(“roshe”, 11, “black”, “fashion”, 129.0, false) String literals should be enclosed in double quotes. As for your change in size type, pass int array instead of int int s[] = {11,12,13}; Shoe roshe = new Nike(“roshe”, s, “black”, “fashion”, 129.0, false) or Shoe roshe = new Nike(“roshe”,new int[]{11, 12, 13} , … Read more

[Solved] Title Name not showing and background color not changing

Your MessageRouter is missing default processing. Add DefWindowProc as shown LRESULT CALLBACK AbstractWindow::MessageRouter ( HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param ) { AbstractWindow* abstract_window = 0; if ( message == WM_NCCREATE ) { abstract_window = ( AbstractWindow* ) ( ( LPCREATESTRUCT ( l_param ) )->lpCreateParams ); SetWindowLong ( hwnd, GWL_USERDATA, long ( abstract_window … Read more

[Solved] What is more Efficient? Implementation in overloaded function or by checking object type in Base class function

For many reasons – code maintainability, extensibility, concision, reliability, minimising the amount of code that needs to be recompiled/redistributed to pick up changes in some library code it uses – you should almost always use virtual functions rather that writing your own switching mechanisms. If you need to ask about it on stackoverflow, I’d go … Read more