Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

could anyone tell plz that why only dot is used for denoting dot operator in c++?

OpenStudy (anonymous):

I'm confused, as opposed to what?

OpenStudy (anonymous):

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.

OpenStudy (anonymous):

1st sentence above, "possive" should be "possessive".

OpenStudy (anonymous):

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

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!