0
for what are assignment operators and objects used for in C++.....??????
4 Answers
+ 8
Every variable is a memory space defined by four main properties: address, datatype, name and value. When you use assignment operator it locates value to the right of = sign into the memory space which can be accessed by the name (or pointer) to the left of it
When it comes to object-oriented programming you will be able to create your own data types and every instance (again memory space) of that class is an object
+ 1
You need the assignment operator to assign a ( new ) value to a variable.
An object is an instance of a class or a struct.
You use objects to encapsulate data and behaviour that operates on this data. It's called objectoriented programming. e.g. You have a class Person, and then you create an instance of the class. Like that:
class Person{
public:
string name;
}
int main()
{
//create a Person
Person spiderman;
/*then you use the assignment operator to assign a value*/
spidername.name = "Peter Parker";
}
It's not the best example but I hope you get an idea for what these things are used for.
+ 1
So much Thanks to all of you
for helping me...
!!..No"lulugo" it was a really helpful example
0
assignment operators- used for storing values onto variables.
objects - instance of a class ,used when you want to create different elements with the same properties but different values.