Methodname" vs "a.MethodName" I would like to know the difference between the two (sorry, I do not know the name of this topic)....">

Cpp. NET: "a-> Methodname" vs "a.MethodName"

I would like to know the difference between the two (sorry, I do not know the name of this topic).

I came from C # where I used to write System.data as well as classA.MethodA. I already found out that in Cpp with namespaces I need to use ::, with classmembers →. But what about the simple "."? I created a connection System :: data: odbc :: odbcConnection ^. Later I was able to use connection.Open. Why not connection-> open?

I'm sorry, I'm sure it’s easy to find something on the net, but I don’t know the English term for them. Thanks guys,

+3
source share
4 answers

If you have a pointer to an object, you use:

MyClass *a = new MyClass();
a->MethodName();

, , :

MyClass a;
a.MethodName();
+4

, ^ V++ * . "" , . . Google:

http://blogs.msdn.com/branbray/archive/2003/11/17/51016.aspx

, , , :

System::Data::Odbc::OdbcConnection connect;
//You should be able to do this:
connect.Open();

, :

System::Data::Odbc::OdbcConnection^ connect1 = gcnew System::Data::Odbc::OdbcConnection();
connect1.Open(); // should be an error
connect1->Open(); //correct
+2

: ++ . , , ( , , ).
a.Method() a , Method.
a->Method() a , Method.

0

a- > , . a.member, , .

I made a quick Google for you and THIS looks pretty fast and decent.

0
source

Source: https://habr.com/ru/post/1721810/


All Articles