C ++ - Is it correct to create new types using using?

1
Once in a post here in the sopt vi that creating new types in C ++ with typedef should be a practice to be abandoned since this is a practice of C, and in C ++ the correct one would be to use using nomedotipo = tipo; , so using this new way I could see that visual studio despite creating a new type, it also created another called unnamed structure:

    
asked by anonymous 21.12.2018 / 12:44

1 answer

1

The using can be parameterized, typedef can not be parameterized. Except for that they are identical.

I do not know why Visual Studio gets complicated. Qt Creator also shows in a strange way. I have not tried other IDEs.

    
21.12.2018 / 13:10
Ionic 3 LocalStorage disappearing ___ ___ erkimt problems StrictMode.ThreadPolicy ______ qstntxt ___

Hello, I have the link below

link

handing me a string %code% % type

%pre%

So, in %code% , handle it with% %code% below:

%pre%

This %code% % works normally. However, you need to put the code snippet below;

%pre%

Otherwise, the connection to the internet is NOT established.

However, I've added the INTERNET access permission on the %code% .

%pre%

But no use.

If I remove this block of code

%pre%

The connection to %code% does not.

The problem is that if I work that way, as often as the ones I need to access the %code% % is the same number of times you have to make use of this code snippet.

Is not there a general configuration file for this in %code% %?

Following the %code% % JsonClass

%pre%     
______ azszpr352394 ___

What happens is that your %code% tries to access the network (a blocking operation) in the main Android thread, which is not allowed.

You can read more about this , but to summarize: A The main Android thread is responsible for updating the views.

Doing blocking tasks such as accessing the network or the database in this thread causes the view to crash, giving that impression of lag in the application.

The above link also gives you an alternative to solve this problem: do this type of tasks within AsyncTasks .

I particularly prefer to delegate all this work to libraries like Retrofit .

Doing what you want with this lib is very trivial:

After adding dependencies , define the contract on an interface:

%pre%

Starts the service instance:

%pre%

And to consume the service in a non-blocking way, just call:

%pre%

Now, within the callback %code% you already have the webservice response parseada and ready to use.

    
___