+ 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.

25th Jan 2018, 4:30 PM
Jacob Pembleton
Jacob Pembleton - avatar
5 Answers
+ 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.
27th Jan 2018, 6:13 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 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.
26th Jan 2018, 4:13 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 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.
26th Jan 2018, 5:25 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 3
No it can have different syntax, but just no data types. JS would be a better example: var hi; hi = “$”; hi = 3;
27th Jan 2018, 12:13 AM
Jacob Pembleton
Jacob Pembleton - avatar
+ 2
@Jacob Pembleton So all we need to do is declare a class without a name, which is obviously not easy. Ill just try.
26th Jan 2018, 5:54 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar