Stock analysis for Citigroup Inc (C:New York) including stock price, stock chart, company news, key statistics, fundamentals and company profile. #1 Mengenal Bahasa Pemrograman C. Jadi, singkat cerita pada awal tahun 1970-an seorang bernama Bjarne Stroustrup mulai mengembangkan bahasa pemrograman c yang merupakan turunan dari Bahasa C. Jika Bahasa C merupakan bahasa prosedural maka Bahasa C hadir menggunakan konsep pemrograman berorientasi objek atau Object Oriented Programming. C profile material C profile length C profile B b H s L p Article ID CAD Galvanized steel C profile (3,048mm 10 ft.) C1 24 5.2 17.5 1 -351120001 Galvanized steel C profile (3,048mm 10 ft.) C3 20 10 10 1.5 -351120003 Galvanized steel C profile (3,048mm 10 ft.) C4 50 10 35 2 -351120004 Galvanized steel C profile (3,048mm 10 ft.) C5 28 12.
- C++ Basics
- C++ Object Oriented
- C++ Advanced
- C++ Useful Resources
- Selected Reading
C/C++ arrays allow you to define variables that combine several data items of the same kind, but structure is another user defined data type which allows you to combine data items of different kinds.
Structures are used to represent a record, suppose you want to keep track of your books in a library. You might want to track the following attributes about each book −
- Title
- Author
- Subject
- Book ID
Defining a Structure
Program C++ Biodata Diri
To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member, for your program. The format of the struct statement is this −
![C++ C++](https://images.squarespace-cdn.com/content/v1/5d89d7bdcd6a2255c38a3aa1/1571644266116-O850O43S3XXKUPVXBOU8/ke17ZwdGBToddI8pDm48kNvT88LknE-K9M4pGNO0Iqd7gQa3H78H3Y0txjaiv_0fDoOvxcdMmMKkDsyUqMSsMWxHk725yiiHCCLfrh8O1z5QPOohDIaIeljMHgDF5CVlOqpeNLcJ80NK65_fV7S1UbeDbaZv1s3QfpIA4TYnL5Qao8BosUKjCVjCf8TKewJIH3bqxw7fF48mhrq5Ulr0Hg/Muse+Fullscreen+2.png)
The structure tag is optional and each member definition is a normal variable definition, such as int i; or float f; or any other valid variable definition. At the end of the structure's definition, before the final semicolon, you can specify one or more structure variables but it is optional. Here is the way you would declare the Book structure −
Accessing Structure Members
To access any member of a structure, we use the member access operator (.). The member access operator is coded as a period between the structure variable name and the structure member that we wish to access. You would use struct keyword to define variables of structure type. Following is the example to explain usage of structure −
When the above code is compiled and executed, it produces the following result −
Structures as Function Arguments
You can pass a structure as a function argument in very similar way as you pass any other variable or pointer. You would access structure variables in the similar way as you have accessed in the above example −
When the above code is compiled and executed, it produces the following result −
Pointers to Structures
You can define pointers to structures in very similar way as you define pointer to any other variable as follows −
Now, you can store the address of a structure variable in the above defined pointer variable. To find the address of a structure variable, place the & operator before the structure's name as follows −
To access the members of a structure using a pointer to that structure, you must use the -> operator as follows −
C++ Bit Data Type
Let us re-write above example using structure pointer, hope this will be easy for you to understand the concept −
When the above code is compiled and executed, it produces the following result −
The typedef Keyword
![C++ big data library C++ big data library](https://1.bp.blogspot.com/-emIyFPGfFt8/W8v5XewK-RI/AAAAAAAAALU/8KrMHRTwd0YoX74GATcgWQEiVi8zG508ACLcBGAs/s400/b16.txt.png)
The structure tag is optional and each member definition is a normal variable definition, such as int i; or float f; or any other valid variable definition. At the end of the structure's definition, before the final semicolon, you can specify one or more structure variables but it is optional. Here is the way you would declare the Book structure −
Accessing Structure Members
To access any member of a structure, we use the member access operator (.). The member access operator is coded as a period between the structure variable name and the structure member that we wish to access. You would use struct keyword to define variables of structure type. Following is the example to explain usage of structure −
When the above code is compiled and executed, it produces the following result −
Structures as Function Arguments
You can pass a structure as a function argument in very similar way as you pass any other variable or pointer. You would access structure variables in the similar way as you have accessed in the above example −
When the above code is compiled and executed, it produces the following result −
Pointers to Structures
You can define pointers to structures in very similar way as you define pointer to any other variable as follows −
Now, you can store the address of a structure variable in the above defined pointer variable. To find the address of a structure variable, place the & operator before the structure's name as follows −
To access the members of a structure using a pointer to that structure, you must use the -> operator as follows −
C++ Bit Data Type
Let us re-write above example using structure pointer, hope this will be easy for you to understand the concept −
When the above code is compiled and executed, it produces the following result −
The typedef Keyword
There is an easier way to define structs or you could 'alias' types you create. For example −
Now, you can use Books directly to define variables of Books type without using struct keyword. Following is the example −
Coding C++ Biodata
You can use typedef keyword for non-structs as well as follows −
x, y and z are all pointers to long ints.