I am confused by why classes are considered data types.
I understand that some of them are “data”, and the other part is methods. Why are they called data types?
Procedures in procedure programming languages, such as C, sometimes contain one or more fundamental data types. But they are not called data types.
Given the definition on Wikipedia:
[...] ( ) - , , , , ; , ; .
, , , C, .
() , . , .
C , , , , .
, , ( ) , .
- - , (ADT). :
(ADT)?
ADT , . , ADT.
,
(ADT) , ; , . , , , (, , ) .
, , ( , private ), ( -).
private
"" . , . , , - . , , "" .
, , . , , ( , , ). :
class Foo { ... }; void main() { Foo bar; Foo *baz = new Foo; delete baz; } void useFoo(Foo &blah) { blah.doSomething(); ... }
, , , . , , ( , "+" .)
, . , , , , .
. , "" - , , ( ), :
typedef void (*function_type)(void *);
:
void(*pf)(void *);
, typedef, function_type. : , ...
typedef
function_type
, , - " ", .
, , , , , .
Confusion, disintegration, combining data and procedures and defining non-essentials - this is what the OOP approach is.
Google "what's wrong with object oriented programming" for some direct answers.