correction?

I wrote this for a brief clarification for myself, are those define correction?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 data        // Data is any sequence of symbols (numbers, letters, etc...) that can be interpreted to mean something. //
    Example
        x,b,$,mike

value        // A value is a single piece of data stored in memory //
    Example
        a number
        a letter
        text

variable    // A variable is a named region of memory
    Example
        int mike (mike is variable)

identifier   // An identifier is the name that a variable is accessed by. Inside the bracelet is Identifier //
    Example
        int mike (identifier is the name of variable such as mike)

type         // A type tells the program how to interpret a value in memory. //
    Example
        int
        double
        float

integer     // An integer is a number that can be written without a fractional component. //
    Example
        int x = 4   // is integer number
        int b = 4.3 // is not integer number


One of tutorial said I should use direct initialization. But the thing is

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

int main ()
{
    int width;
    width(10);

    width(7);

        std::cout << width;
    return 0;
}


int (10); doesn't work, the error are showing.

width cannot be used as a function
Last edited on
1
2
3
4
int width;
    width(10);

    width(7);


A variable is only initialized 1 time. So, int width; is the initialization.

The lines where you are assigning values should be assignment statements, not initialization.

These should work.

1
2
int width{10};
width = 7;
Wow, I definitely didn't read that tutorial carefully. Thank you
Topic archived. No new replies allowed.