I have a struct in C++
typedef struct DIFColor
{
uint8_t r;
uint8_t g;
uint8_t b;
} DIFColor;
And am trying to initialize it like this:
DIFColor d = new DIFColor();
d.r = r;
d.g = g;
d.b = b;
But the compiler complains about not being able to convert a pointer to a regular variable. What pointer? From this question I thought you could simply create a new struct without having to deal with pointers and dynamic memory allocation with new
. Does it have something to do with the fact that I am initializing the struct like one would in C, instead of using a constructor?
error: conversion from 'DIFColor*' to non-scalar type 'DIFColor' requested