473,385 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

; in function member declaration

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
2 1767
* 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: kazack | last post by:
I am a little confused with code I am looking at. My c++ book does not go into passing a structure to a function so I pulled out a c book which does. and I do not understand the prototype verses...
3
by: Dave | last post by:
Hello all, I am trying to create a full specialization of a member function template of a class template. I get the following errors: Line 29: 'foo<T1>::bar' : illegal use of explicit...
2
by: joe | last post by:
hi, after reading some articles and faq, i want to clarify myself what's correct(conform to standard) and what's not? or what should be correct but it isn't simply because compilers don't...
7
by: Jimakos Bilakis | last post by:
Hi guys! I'm using the C++ Builder 6 Enterprise Edition where I create some tables in Paradox and with the help of a structure i pass my data from the form (Edit boxes) to the Paradox table with...
4
by: Joseph Turian | last post by:
Hi, What is the correct syntax to get the bar<T>::f<int, unsigned>() function to compile in the following fragment? Thanks, Joseph class foo {
1
by: yancheng.cheok | last post by:
currently, i have a private function in cat named privateFun. i would like to have this function "private" to all except dog's action member function. by using the following approach, all the...
4
by: Paulo Matos | last post by:
Hi all, I'm trying to work out a parser for function declarations but it turns out that it is harder than I initially thought. I'm looking at 3rd Ed of Stroustrup, page 808. I'm trying to parse...
6
by: Joseph Turian | last post by:
I am having difficulty defining a friend function because of a #include cycle: ============ obj.H ================ #ifndef _obj_ #define _obj_ #include "cont.H" class cont;
5
by: Marcin Gil | last post by:
Hi! I have the code like this (obvious things like ctor/dtor removed) typedef struct _NODE { int val; int index; } Node;
10
by: blangela | last post by:
If I pass a base class object by reference (likely does not make a difference here that it is passed by reference) as a parameter to a derived class member function, the member function is not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.