473,385 Members | 1,379 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.

void vs. System::Void

Is there a difference between using the C++ keyword "void" and using
"System::Void" when specifying parameters and return types? Is there a
preference when choosing between the two? In the code I'm working on,
the original author uses both, and I don't understand if there is a
specific reason to choose one over the other in certain situations.

--
Marcus Kwok
Feb 20 '06 #1
2 3413
Marcus Kwok wrote:
Is there a difference between using the C++ keyword "void" and using
"System::Void" when specifying parameters and return types? Is there a
preference when choosing between the two? In the code I'm working on,
the original author uses both, and I don't understand if there is a
specific reason to choose one over the other in certain situations.


Hey Marcus!
Both 'void' and 'System::Void' do exactly the same thing. You can
substitute one for the other in all situations (even to access static
methods of the System::Void class like "void::ReferenceEquals(a,b);").

Brandon

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
Bugs? Suggestions? Feedback? http://msdn.microsoft.com/productfeedback/
Feb 20 '06 #2
Brandon Bray [MSFT] <br******@online.microsoft.com> wrote:
Marcus Kwok wrote:
Is there a difference between using the C++ keyword "void" and using
"System::Void" when specifying parameters and return types? Is there a
preference when choosing between the two? In the code I'm working on,
the original author uses both, and I don't understand if there is a
specific reason to choose one over the other in certain situations.
Hey Marcus!
Both 'void' and 'System::Void' do exactly the same thing.


Hi Brandon,
Thanks for your response. Based on this, I will go ahead and change
them all to just plain "void" for consistency.
You can
substitute one for the other in all situations (even to access static
methods of the System::Void class like "void::ReferenceEquals(a,b);").


Now that just looks bizarre to me :) In that situation (calling static
methods of the System::Void class), I would use the
System::Void::ReferenceEquals(a, b); form, but for specifying return
types, I prefer the standard "void", and for empty parameter lists, I
prefer to leave the parameter list empty (like func() instead of
func(void)).

--
Marcus Kwok
Feb 20 '06 #3

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

Similar topics

5
by: trying_to_learn | last post by:
Hello All Have another qn from the practice exercises. I ve done the exercise and the birds fly member fn was called successfully. But i still cant answer the authors qn. why this ability to...
4
by: Pushkar Pradhan | last post by:
I have some functions which take as i/p a buffer (it can be float, char, or 16 bit, int etc.). The result is another o/p buffer, its type is also flexible (it could be a float, char etc.). I try...
1
by: charles | last post by:
system.void cannot be used from c# -- use typeof(void) to get the void type object
2
by: Judah | last post by:
With generics in .NET 2, there are certain scenarios in which using System.Void would be useful: TReturnType MyFunction<TReturnType>() { return default(TReturnType); } Above is a simple...
12
by: Bill Pursell | last post by:
The following code generates a compiler warning when compiled with gcc -pedantic: typedef (*FUNC)(int); FUNC f; void * get_f(void) { return &f;
2
by: sovarschizsuzsa | last post by:
Hy! I have written a MC++ wrapper DLL file for use in a C# project. This wrapper DLL is built on a C DLL. I have the following functions in the C DLL: int First(char* a1, char* a2, void* *a3,...
0
by: Just D. | last post by:
Does anybody know what's that below? I've never seen this kind of exceptions. We started getting this exception report (everything's going right to my email with some additional details) after we...
1
nomad
by: nomad | last post by:
Hi everyone: This project is driving me crazy and I need some help. I would post it here but I have worked so hard on it that I don't want someone else in my class to steal it. So if I can pm it...
3
by: vijay.gandhi | last post by:
Hi, I am trying to convert some unmanaged code (C++) to managed code (using C++/CLI). 1) One of the functions used returns a void* which I need to cast into a handle of a managed object. Can...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.