Having a new class/struct/interface type act as substitute for existing one
Asked Answered
W

4

0

Attempting to implement a solution where classes, structs and more (types) could be substitutions for existing ones. So for example, I could have the following in code further down the line where the copy types would actually be used.

Vector3Clone newvector3 = new Vector3Clone();

Implementation seemed like a fine solution (public partial class InputEventClone: InputEvent), however it doesn't seem like all of the functionality can be mimicked with structs for example and it doesn't appear that you can implement a struct the same way at all. Even with classes there can be constructor issues. I'm hoping for simple solutions that may work at least for each type of class, struct, interface and so forth. Is this possible or would it always be a requirement to have more specific functionality passed along for several functions within each existing type, like with their constructors or operator overrides?

Wavell answered 26/10, 2023 at 17:9 Comment(0)
C
0

Wavell What do you need this for?

Catch answered 26/10, 2023 at 17:20 Comment(0)
W
0

It would be an API of sorts I suppose. But there's no point in spending much time on this if it's not really feasible from what I've described.

Wavell answered 27/10, 2023 at 14:40 Comment(0)
L
0

You can define your own constructor and then call the inherited constructor internally. And virtual functions to just call the parent class if they are not implemented? I'm not sure what you are saying, but if this is c++ it should be possible to extend a class very easily. Unless the parent class doesn't allow you to override. You can overload functions with the same name with more parameters in the function declaration.

Loanloanda answered 28/10, 2023 at 2:46 Comment(0)
C
0

Wavell It would be an API of sorts I suppose

It would obviously be an api, but what purpose would it serve? Why do you want or need to substitute an existing one?

Catch answered 28/10, 2023 at 3:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.