C++ Syntax | C++ Basic Syntax - Learn C++ , C++ Tutorial , C++ programming
Syntax in C++
- When we consider a C++ program, it can be defined as a collection of objects that communicate via invoking each other's methods
- Let us now briefly look into what do class, object, methods and Instance variables mean.
Learn C++ , C++ Tutorial , C++ programming - C++ Language -Cplusplus
Object
- Objects have Properties and Behaviors.
- Example: A dog has Properties - color, name, breed as well as Behaviors - wagging, barking, eating. An object is an instance of a class.
- C++ programs create, access, manipulate, and destroy objects. An object is a piece of memory that can be used to store values.
- You can think of an object as a mailbox, or a cubbyhole, where we can store and retrieve information.
- All computers have memory, called RAM (random access memory), that is available for programs to use.
- When an object is defined, a piece of that memory is set aside for the object.
- Most of the objects that we use in C++ come in the form of variables.
learn c++ tutorials - class object model Example
Class
- A class can be defined as a template/blueprint that describes the behaviors/states that object of its type support. A class is a blueprint for the object.
Methods
- A method is basically a behavior. A class can contain many methods .
- It is in methods where the logics are written, data is manipulated and all the actions are executed.
Learn C++ , C++ Tutorial , C++ programming - C++ Language -Cplusplus
Instance Variables
- Each object has its unique set of instance variables.
- An object's state is created by the values assigned to these instance variables.