1static_cast conversion
2 C++ C++ language Expressions
3Converts between types using a combination of implicit and user-defined conversions.
4
5Syntax
6static_cast < new_type > ( expression )
7Returns a value of type new_type.
1typedef struct
2{
3 //add different parts of the struct here
4 string username;
5 string password;
6}
7user; // name of struct - you can name this whatever
8
9user example; //variable of type user
10
11example.username = "Comfortable Caterpillar"; // username part of example variable
12example.password = "password" // password part of example variable
13
14if (user.username == "Comfortable Caterpillar")
15{
16 printf("upvote this if it helped!");
17}
1// typedef [type] [alias]
2// Example:
3typedef unsigned long int ulong;
4
5ulong someNumber = 158426;
1#include <iostream>
2 int main(){
3 typedef unsigned int ui;
4 ui i = 5, j = 8;
5 std::cout << "i = " << i << std::endl;
6 std::cout << "j = " << j << std::endl;
7 return 0;
8}
9
1// simple typedef
2typedef unsigned long ulong;
3
4// the following two objects have the same type
5unsigned long l1;
6ulong l2;
7
8// more complicated typedef
9typedef int int_t, *intp_t, (&fp)(int, ulong), arr_t[10];
10
11// the following two objects have the same type
12int a1[10];
13arr_t a2;
14
15// common C idiom to avoid having to write "struct S"
16typedef struct {int a; int b;} S, *pS;
17
18// the following two objects have the same type
19pS ps1;
20S* ps2;
21
22// error: storage-class-specifier cannot appear in a typedef declaration
23// typedef static unsigned int uint;
24
25// typedef can be used anywhere in the decl-specifier-seq
26long unsigned typedef int long ullong;
27// more conventionally spelled "typedef unsigned long long int ullong;"
28
29// std::add_const, like many other metafunctions, use member typedefs
30template< class T>
31struct add_const {
32 typedef const T type;
33};
34
35typedef struct Node {
36 struct listNode* next; // declares a new (incomplete) struct type named listNode
37} listNode; // error: conflicts with the previously declared struct name