473,385 Members | 2,015 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.

why void and why not void as a return type

As a method returns a int value we have return type as a int and if method returns nothing we use return type as a void.
If the method is not returning anything then why should we use void. I know that without giving the return type to a method it will give an error. But my question is why void if a method return nothing.
eg:
void abc()
{
stat1;
....;
}
why not
abc()
{
stat1;
....;
}
Sep 19 '10 #1
2 1425
Expand|Select|Wrap|Line Numbers
  1. abc()
  2. {
  3.  ....
  4. }
  5.  
is a constructor. It is required to specify return type as void if method doesn't return value.
Sep 20 '10 #2
Plater
7,872 Expert 4TB
Technically, at the end of a void function you could explicitly call a
return;
But it is implicitly understood to behave that way.
Sep 20 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: PengYu.UT | last post by:
I have the following sample program, which can convert function object with 1 argument into function object with 2 arguments. It can also do + between function object of the same type. The last...
14
by: zeroDontSpamtype | last post by:
Hi, Why do strcpy and strcat (and strupr and strlwr in some nonstandard implementations) return a char*? Surely the logical (and DMA-safe) )return type for these would have been void?? ...
10
by: geoffblanduk_nospam | last post by:
Just curious, we no longer require void on a method that takes no parameters; void methodWithNoParameters(void) has been replaced by void methodWithNoParameters(). Is there a good reason we...
59
by: Michael C | last post by:
eg void DoIt() { int i = FromString("1"); double d = FromString("1.1"); } int FromString(string SomeValue) {
31
by: CeZaR | last post by:
Hi, How can i specify the return type of a function returning a managed array of chars. If i try to write: "char __gc func()" i get an error! How can i do that? Thanks!
1
by: Thomas D. | last post by:
Hello all, I'm using the IXmlSerializable interface for a project and encounter some problems when testing my webservice in a client application. I know this interface is undocumented and not...
5
by: Shea Martin | last post by:
I have a struct like so: struct MyStruct { public: void Value( int newValue ) { mValue = newValue; } int Value() const { return mValue; } private: int mValue;
10
by: Grizlyk | last post by:
1. Can abybody explain me why C++ function can not be overloaded by its return type? Return type can has priority higher than casting rules. For example: char input(); //can be compiled to name...
5
by: Brian Withun | last post by:
I have a base class (B) and several derived classes (D1, D2, ...) I have a container class (C) with an attribute (void *d) which is intended to point to any of D1, D2,... My question is, on my...
18
by: Carl Forsman | last post by:
there are 2 ways to return a value from a function ==================== 1) passing a reference as parameter - the following will return time void Table::Get(char* FieldName, *SYSTEMTIME time) {...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.