+ 1
CHALLENGE (OOP Data type languages only)
Using a language that does have data types and OOP, create a class (or struct in C) that can act as a variable from a non-data type language, such as Python. It should be able to: >hold a value than switch to an array of values >change the number of dimensions in array form >hold values from any standard data type Rules: No using predefined types that can do some of these tasks (containers in C++). Give examples of using the variable. Most upvotes wins.
5 ответов
+ 5
This is what I could do so far. It does not meet all criteria though, and currently works only for 'primitive' types. I'm still trying...
https://code.sololearn.com/c7dMUYfJ9DR7/#cpp
If possible, can you tell me if such a solution is allowed? If not, then I won't waste time on this anymore then.
+ 4
Sir, what is meant by 'acting as a variable from a non data type language' ? Is is that we have to make a class that will not require a type to be appended to the variable name for declaration? Or is it something else?
I want to try, but it seems I just won't be able to as I couldn't understand what to do.
+ 4
In a language with no data types, you could do something like this:
x = 65;
x += 3;
x = {“hello”, “goodbye”, “string”};
And that would not give an error.
+ 3
No it can have different syntax, but just no data types.
JS would be a better example:
var hi;
hi = “$”;
hi = 3;
+ 2
@Jacob Pembleton
So all we need to do is declare a class without a name, which is obviously not easy. Ill just try.