By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

; in function member declaration

P: n/a
Hi all:

Must I finalice a function member declaration with ; ?

For example;

class A {
...
public:
myFunc(); //Is this ; necessary
};

I compile my programs using Sun's Forte 6 and linux gcc 3.3.2
In this case (with or without ;) compiles ok with both compilers.

But in the next case:

class DatosUssd {

...

template<typename Tabla> static const Tabla& getRefTabla(Tabla*
DatosUssd::*tabla) {
static const Tabla* nullTabla=0;
if(actual)
return *(actual->*tabla);
else
return static_cast<const Tabla&>(*nullTabla);
}; //this ; gives me an error with sun's Forte 6

public: //Compiler error due to the previous ";" character

...
};

With linux gcc, it compiles ok with or without ;
But with Sun's Forte 6 without ; compiles ok, but with ; compiler gives
me the error:
Error: A declaration was expected instead of "public"

I want to know if finalize function members with ; is a compiler error
or mine.
Apr 19 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* Carlos Martinez:
Hi all:

Must I finalice a function member declaration with ; ?

For example;

class A {
...
public:
myFunc(); //Is this ; necessary
};

I compile my programs using Sun's Forte 6 and linux gcc 3.3.2
In this case (with or without ;) compiles ok with both compilers.

But in the next case:

class DatosUssd {

...

template<typename Tabla> static const Tabla& getRefTabla(Tabla*
DatosUssd::*tabla) {
static const Tabla* nullTabla=0;
if(actual)
return *(actual->*tabla);
else
return static_cast<const Tabla&>(*nullTabla);
}; //this ; gives me an error with sun's Forte 6

public: //Compiler error due to the previous ";" character

...
};

With linux gcc, it compiles ok with or without ;
But with Sun's Forte 6 without ; compiles ok, but with ; compiler gives
me the error:
Error: A declaration was expected instead of "public"

I want to know if finalize function members with ; is a compiler error
or mine.


Function declaration: terminating semicolon.

Function definition: no terminating semicolon.

As a simple rule of thumb, never place a semicolon after a right brace
}, except after a class definition, where the semicolon is required.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 19 '06 #2

P: n/a
Alf P. Steinbach wrote:

Function declaration: terminating semicolon.

Function definition: no terminating semicolon.

As a simple rule of thumb, never place a semicolon after a right brace
}, except after a class definition, where the semicolon is required.


Semicolons are permitted after function definitions which occur
inside a class definition.

Apr 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.