473,799 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Declaring varibale name in paren

It seems that a variable can be declared with parenthesis. For example:

int main() {
int (x);
x = 5;
}

In this case it is useless. But is there any circumstances where
parenthesis are really needed ? if not why allow this ?

Thanks you in advance.
Jun 27 '08 #1
1 1402
Josuan wrote:
It seems that a variable can be declared with parenthesis. For example:

int main() {
int (x);
x = 5;
}

In this case it is useless. But is there any circumstances where
parenthesis are really needed ? if not why allow this ?
To declare a reference to an array, for example

int (&x)[5];

or to declare a pointer to a function

int (*ptr)(int,doub le);

In all cases I can think of the parentheses are there to give higher
priority to the asterisk or the ampersand that accompany the variable
name. If the parentheses were omitted, then the former case would be
come an [illegal] array of references to int and the latter would be a
declaration of a function named 'ptr' that returns a pointer to int.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2

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

Similar topics

1
1616
by: moggous phar | last post by:
how i have to declarate stuff like this: typedef struct { PfadIter Parent; CString Name; } PFADSTRUCT; typedef PfadMapType::iterator PfadIter; typedef std::map<PFADSTRUCT, int> PfadMapType; is there any uncomplete decl like
3
2440
by: Mac | last post by:
Is it legal to declare errno after you've included errno.h? For example: #include<errno.h> .... int main (void) {
2
1579
by: Michael Gunter | last post by:
Good afternoon, I am creating an interface in C++ using the managed extensions. I need to declare a parameter as an out string (as would be represented in C#). Does anyone know how to do this? Declaring out parameters generally takes the form: <type> __gc* name and arrays generally take the form:
5
1473
by: Chris H | last post by:
Okay, I am trying to us a varialble with a list of number values as my data for an array, yet when I do this it doesnt return any values from the array, i was able to temporarily fix the proble by just doing s normal array setup in my function, but the problem is I want the ability to have teh array values to be changed easily in a varibale style config/include file... Here is the code i am working with... ...
2
3344
by: pagekb | last post by:
Hello, I'm having some difficulty compiling template classes as containers for other template objects. Specifically, I have a hierarchy of template classes that contain each other. Template class B has an instance of template class A, which has some base type T (usually int or double). However, the base type T is important to calculations in B, so I would like to obtain access to the type for further variable declaration within B. ...
1
1198
by: =?Utf-8?B?TW9uaWNh?= | last post by:
Hi, Sorry, maybe it's so simple. but please let me know. I have Login.aspx.cs taht has a string variable like strUserName. I have manage.aspx.cs that I want to get strUserName. How can I do this? Thank you. Monica
8
7521
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring and initializing variables inside a loop routine, like this: for(var i=0; i<list; i++) { var name = list; }
1
1305
by: dankingsley | last post by:
Hi. I'm not that good with php, and i'm having a bit of a problem with inserting an image with a variable file name. I'm actually trying to create a facebook app, but Im pretty sure the problem isn't to do with that! The code is: $fbml = '<img border="0" src="http://www.dankingsley.co.uk/yorkuniversitycolleges/images/$image.jpg" width="200" height="300">'; $facebook->api_client->profile_setFBML($fbml, $user); I'm just not sure how...
3
2263
by: Bubba | last post by:
Hi all, I've got an XSD file that I need to add support to for an optional ID attribute on elements. After many hours of tweaking all that I get to work in my XML file is: <Container id="CT"<!-- Valid ID declaration --> <Stuff id="CT-1">Foo Bar</Stuff<!-- Invalid ID declaration--> </Container>
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10488
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10237
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
9077
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...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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...
1
4144
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
3
2941
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.