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

Asked

Viewed 47 times

1

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

inserir a descrição da imagem aqui

  • I don’t understand what you want to know and what this screen has to do with the question. Part of the problem may be because it confuses the functions of things, see https://answall.com/q/101691/101 Or it may just be that the question is incomplete and not saying what is important to understand the doubt.

  • @Maniero I wondered if creating new types with using is correct or is just a "gambiarra", what made me ask the question was that vstudio have indicated that the new type is also an unnamed structure, as if it were a problem as shown in the image

  • 1

    If you read here someone saying it is correct, why are you suspicious? Was the answer negative? Is there anything more than just wanting confirmation that that is true? Where is this that you are saying indicated? Usually the using not to use so, must have a reason, I said normally, this seems a case to only declare the struct normally, without using and without typedef.

1 answer

1


The using can be parameterized, the typedef no. Except that they are identical.

I don’t know why Visual Studio gets complicated with this. Qt Creator also shows in a strange way. I haven’t tried other Ides.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.