Help with struct

Hi, could someone please help me understand the following code:

1
2
3
struct TypeClass
{   TypeClass (Type t, const char **c) :: t(t), c(c) {}
};


Advanced thanks.
I also have problems understanding it. Because it doesn't work. The initialization list is wrong and the attributes are missing.
You have a struct that contains a constructor. This function is called when you create an instance of the struct to initialize the member variables (fields).

The double colon (::) is a syntax error. It should be a single colon. t(t) and c(c) mean that the member variables t and c are initialized with the value of the parameters t and c respectively. Of course it's an error if these member variables don't exist.

Your code should look like this to be correct:
1
2
3
4
5
struct TypeClass
{   Type t;
    const char ** c;
    TypeClass(Type t, const char **c) : t(t), c(c) {}
};


It is similar to this: (but not exactly the same)
1
2
3
4
5
6
7
8
struct TypeClass
{   Type t;
    const char ** c;
    TypeClass(Type t, const char **c) {
        this->t = t;
        this->c = c;
    }
};
Topic archived. No new replies allowed.