methods - Difference between }; and } in C++ -


New to C ++.

Vocational on a project for assignment, and some examples found in end-ended methods with in i}}; Typical (expected)}

instead of:

  Circuit buffer :: Circumbfer () {cout & lt; & Lt; "Named Constructor \ n"; Cout & lt; & Lt; "Buffer" & lt; & Lt; Buffer Size & lt; & Lt; "Elements \ n"; For (Int i = 0; I & lt; = Buffer Size -1; I ++) {Buffer [i] = 0; } ReadIn = WriteIn = 0; SetDelay (0); };  

Thank you, Louise

I am not getting any information why this will be done online < P> / div>

that runs under that name; In the name space, an empty declaration is seen as your compiler in the code given above

  circuit buffer :: circuit buffer () {...} // & lt; - 'Circuit buffer :: Circbuffer' definition ends here; // & lt; - An empty declaration which declares nothing   

I.e. Law definition is actually }; does not end with the compiler's approach it ends with } , and ;

The empty manifestation was illegal in C ++ and the original version of C + 03 03, but it was valid in C ++ 11. The code you extract is invalid in C + + 98 and C + 03 03, but is legal in C ++ 11, however, the C + + 98 compiler often supports empty announcements in the form of non-standard extensions.

Note that the above only applies to the outside range function definitions (as per your example). With classic member function definitions, the previous ; Always Legal (and Optional)

  Class C {C () {...}; // & lt; - ';' Not required, but also legal C + + 98};   

(In this case optional, ; is actually a part of member definition, which means that the definition actually ends in }; < / code> and does not start an empty declaration.)

When you see something like this in the actual code, it is probably just a bad habit, perhaps that the basis of confusion between class and out On, class definition references.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -