vendredi 23 janvier 2015

class in OOP language and type


In programming language theory, a type is a set of values. E.g. the type "int" is the set of all integer values.


In OOP languages, a class is a type, is it?


When a class is defined with more than one members, e.g.



class myclass{
int a;
double b;
}


When we talk about a class, do we mean



  • "(a,b) where a is an int and b is a double", or

  • "{(x,y) | x is any int, y is any double}"?


What does an instance of myclass mean?



  • "(a,b) where a is an int and b is a double", or

  • an object which occupies a memory space and which can (not necessarily, i.e. can be empty) store (x,y), where x is any int and y is any double?





Aucun commentaire:

Enregistrer un commentaire