0% found this document useful (0 votes)
45 views

What Is A Class?: Oops - Object Oriented Programming Languages & Systems

Everything in the world is an object. The type of the object may vary. In OOPS, we get the power to create objects of our own, as and when required.. A class is simply a representation of a type of object. It is the blueprint / plan / template that describe the details of an object.

Uploaded by

akm_anand
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

What Is A Class?: Oops - Object Oriented Programming Languages & Systems

Everything in the world is an object. The type of the object may vary. In OOPS, we get the power to create objects of our own, as and when required.. A class is simply a representation of a type of object. It is the blueprint / plan / template that describe the details of an object.

Uploaded by

akm_anand
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

OOPs - Object Oriented Programming Languages & Systems Everything in the world is an object.

The type of the object may vary. In OOPS, we get the power to create objects of our own, as & when required. OOPs is a programming methodology where each entity is an object. It is a method of computer programming where entities of related data together with routines associated with it are treated as one object in the program. Everything in OOP is grouped as self sustainable "objects". Hence, you gain re-usability by means of four main object-oriented programming concepts.

What is a Class?

A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.

About Value Types and Reference Types

Value and Reference Types


If you know C and C++ then you'll be familiar with the difference between local or auto variables and pointer/reference variables that are created on the heap. It's similar for C# value types and reference types.

The Heap and The Stack


Procedural programming languages that let you to create variables dynamically at run-time use two different areas of Ram for holding variables;. the stack and the heap. The heap is basically all unallocated memory. The picture shows a rough layout of a program in memory. The first four areas (Program Code, Static Data, Uninitialized Data and Stack) are fixed in size when the application is linked and the heap is what's left over. This is for each application, but because of the way a CPU virtualizes memory, each application runs in its own space and sees itself as having access to all available ram. The stack holds value type variables plus return addresses for functions. All numeric types, ints, floats and doubles along with enums, chars, bools and structs are value types. The heap hold variables created dynamically- known as reference variables and mainly instances of classes or strings. These variables are stored in two places; there's a hidden pointer to the place in the heap where the data is stored. Another distinction between value and reference type is that a value type is derived from System.ValueType while a reference type is derived from System.Object.

If you assign a value type variable to another then a direct copy of the value is made. But copying a reference type variable just makes a copy of the reference to the variable and does not affect the variable itself. This is like pointers in C and C++. You aren't copying what the pointer points to but making a copy of the pointer itself. Structs are Lightweight Objects In C++ a struct is just a class with default public access. In C# it is like a class but much more limited and is a value type so is stored on the stack. It is closer to the original use of a struct in C where it was just a place to hold data. A struct cannot inherit from a struct not can it be inherited from. To confuse matters slightly, a struct can contain constructors, constants, fields, methods, properties, indexers, operators, events, and nested types. A default constructor is provided by the compiler so you can initialize it with constructor type syntax. But you cannot write a default constructor for a struct yourself. Any constructors you write for a struct must have parameters.

You might also like