473,394 Members | 1,812 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,394 software developers and data experts.

what is the purpose of these??

2
{ }
( )
[ ]

those are parts in making a c++ program..
but what is the purpose or meaning of those parts??
Feb 21 '07 #1
3 1091
horace1
1,510 Expert 1GB
{ }
( )
[ ]

those are parts in making a c++ program..
but what is the purpose or meaning of those parts??
you not only need to know what they mean but also to understand where they are used, have a read thru the C++ tutorial
http://www.cplusplus.com/doc/tutorial/
Feb 21 '07 #2
{} is used for two purpose one is to initialise multi dimesinal array and another place is to define the body of the function...

( ) is used while calculation similar to mathematics....some times it may used in the specify the subset of the array but that is not a common.....

[] is used for denoting the subset of the array...


Better read tutorial link provided by the Horac1 to know more and clearly....
Feb 21 '07 #3
DeMan
1,806 1GB
Expanding a little furhter on the answer....
{} is used for two purpose one is to initialise multi dimesinal array and another place is to define the body of the function
{} are used not just to define the body of a function, but more generically to execute a block of statements. Most commonly this is if you want a conditional statement or loop to execute more than one statement, you put these parentheses around all the code you want executed in that condition.
eg:
Expand|Select|Wrap|Line Numbers
  1. if(something)
  2. {
  3.    printf("somethind is true");
  4.    doSomethingElse();
  5. }
  6.  
Without the parentheses, the program would execute the printf if something is true and the doSomethingElse method irrespective of the value of something. (I'm starting to think something is a bad variable name)


( ) is used while calculation similar to mathematics....some times it may used in the specify the subset of the array but that is not a common
() is used to explicitly show order of computation. This is for logical and computational values. () are also required to define parameter lists for functions (and must still be included is there are no parameters), and are required as part of the syntax of some statements.
It is always better to include too many rather than too few of these (assuming they're in the right place, because their placement can affect the result of an expression). Consider what the boolean logic below does and when it returns true
Expand|Select|Wrap|Line Numbers
  1. boolean this, that, what
  2. if(this && that || what == true)  i
  3.  
  4. //is this the same
  5. if((this && that) || what)  
  6. /* Requires that either both this AND that are true OR at least what is true */
  7.  
  8. // or maybe
  9. if((this && (that || what))
  10. /* require that this is true AND either that or what is true*/
  11.  
  12.  
Feb 21 '07 #4

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

Similar topics

23
by: darwinist | last post by:
What PHP Represents There is no shortage of complaints one could make about php as a language, and although the list does shrink with each release, some of them are inherent to the origins and...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
4
by: Ruud de Jong | last post by:
The question I have is: how safe / future proof / portable is the use of the __subclasses__ method that exists for new-style classes? Background: I thought I had found an easy-to-understand...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
12
by: Peter Morris | last post by:
What, exactly, is ASP? Is ANY dynamically generated HTML the same as ASP? Or does ASP have to be in a particular format or language? The company I used to work for (until it went bust) was in...
9
by: Qiao Jian | last post by:
I am new to c. Today I just read an h file within which there is statements: #ifndef _RANDOM_H #define _RANDOM_H So what is the meaning or purpose of this statement? When should I use such...
14
by: copyco | last post by:
Can anyone tell me what the purpose is to adding items such as a VBScript file or HTML document to your VB.NET project? Once you have these things added, how to you access them and use them in...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
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:
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: 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
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
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...

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.