Suppose I declare a new type of C ++ structure:
struct my_struct { int a; int b; };
Can I create a new instance of this type of structure with:
my_struct foo;
or
struct my_struct foo;
If both work, is there a difference?
Yes, you can use any of these methods. The difference is that this form:
It is not legal in C, so you should use this form:
What is supported in C ++ for backward compatibility with C.
Both work. The main reason for the second work is compatibility with C: In C the first does not work. As a result, struct usually typedef ed in C and there are two different name types for struct and typedef s.
struct
typedef
Source: https://habr.com/ru/post/1438311/More articles:A strange problem with multi-pass, multi RT RT in GLSL - shaderPlayFramework Multiple Bindings SLF4J - javaHow to parse a time string to a specific time zone? - timezoneGet elements of the current view / filter in Sharepoint 2010 - using the client object model - viewWorking with exception handling and re-queuing in RQ on Heroku - pythonScalable / Replicated Database - cassandraWhat is the "elegant" method of using BackOffPolicy - javaOpenGL why not choose a shader program? - shaderIs glDisableClientState required? - openglResizing an image in php on startup rotates the image when I don't want it to be - phpAll Articles