could anyone tell plz that why only dot is used for denoting dot operator in c++?
I'm confused, as opposed to what?
Dot operator is sort of like the possive in English or another language. For instance, if X in a desk, then X's top surface might be X.topsurface. I'm using another similar language, not C++, as my reference re this usage, but believe that is right for C++ also. How does the possessive work in Hindi? Isn't it "ka"? Would "X ka desktop" be the way to say that in Hindi? If so, a direct equivalence to C++ syntax. Hope that little bit helps. Best wishes.
1st sentence above, "possive" should be "possessive".
the dot operator pretty much allows u to access fields of a structure or a class... for example u have a class: class MyClass{ public: int x; double y; } main() { MyClass exp; //if u want to access variable x that is related to object exp exp.x=5; //same thing for y exp.y=5.3; return 0;} PS. this is not the proper way to access class variables ((we usually do so with functions)) but it just for demonstrating the operator u can do the same thing with struct members ...hope this helped
Join our real-time social learning platform and learn together with your friends!