473,659 Members | 2,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"virtual public" vs "public virtual"

Syntax seems to say "modifiers is modifiers" and either is valid, but
Google searches seem to show that "public virtual" is more common.

Is there any sort of (semi) official convention?

--

programmer, author http://www.midnightbeach.com
and father http://www.midnightbeach.com/hs
Nov 15 '05 #1
4 8493
The generally followed convention is:

<access specifier><over ride/virtual/abstract...><re turn-type><Method name> (<params>)

This convention is what I had seen almost always which may be considered as official :). But nevertheless, some ppl (though very rare) do use the other one too.

Regards,
fbhcah
Nov 15 '05 #2
Jon Shemitz wrote:
Syntax seems to say "modifiers is modifiers" and either is valid, but
Google searches seem to show that "public virtual" is more common.

Is there any sort of (semi) official convention?


I guess there isn't. However, many C#ers are coming from C++ where you had
to split the interface into public, protected and private *sections*:

class X
{
public:
void F();
void Y();
protected:
void Z();
private:
int x;
};

So having the access specifier first is more natural, to people coming from
C++, that is...

Regards,

Andreas

P.S. I'm unsure whether Java has any restrictions here...

Nov 15 '05 #3
Andreas Huber <ah****@gmx.net > wrote:
P.S. I'm unsure whether Java has any restrictions here...


Nope. So long as the return type is immediately before the method name,
the rest is fine.

The conventions are the same though.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4

"Andreas Huber" <ah****@gmx.net > wrote in message
news:40******** **@news.bluewin .ch...
Jon Shemitz wrote:
So having the access specifier first is more natural, to people coming from C++, that is...

Regards,

Andreas

P.S. I'm unsure whether Java has any restrictions here...


Java does not have any such restrictions (except virtual is not a keyword as
everything is virtual in Java).

However, as Java, Delphi, Visual Basic and just about every language there
is have as convention of specifying scope before modifiers and I would hate
to see 'virtual public' being used. For me, it simply looks wrong.

Programmers looking for modifiers will scan the second word first, why
confuse them. =)

- Michael S

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
1897
by: mshetty | last post by:
Hi, I get an error "Warning: b::a_method hides the virtual function a::a_method()." on compiling the following code.. #include <iostream.h> class a {
6
9747
by: kelvSYC | last post by:
This little bit of seeminly innocent code seems to give me these two errors, all on the line that declares check(). Is there some part of C++ that I'm missing out on? class Condition { public: Condition() {} virtual ~Condition() {} virtual bool check() const;
175
8773
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be changed". This is very much against my instincts. Can anyone offer some solid design guidelines for me? Thanks in advance....
7
2473
by: desktop | last post by:
This page: http://www.eptacom.net/pubblicazioni/pub_eng/mdisp.html start with the line: "Virtual functions allow polymorphism on a single argument". What does that exactly mean? I guess it has nothing to do with making multiple arguments in a declaration like:
0
8335
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.