Question

I have this struct:

#pragma once

#include "Defines.h"

#ifndef _COLOR_H_
#define _COLOR_H_

namespace BSGameFramework
{
namespace Graphics
{
    ref struct Color
    {
        public:

            Color(BYTE r, BYTE g, BYTE b);
            Color(BYTE r, BYTE g, BYTE b, BYTE a);
            Color(Color% color) {};

            static property Color White
            {
                Color get()
                {
                    Color white = gcnew Color(255, 255, 255);

                    return white; // Here the error
                }
            }

        private:

            BYTE r;
            BYTE g;
            BYTE b;
            BYTE a;
    };
}
}

#endif

and when I'm compiling the file I'm getting this error:

Error 1 error C2664: 'BSGameFramework::Graphics::Color::Color(const BSGameFramework::Graphics::Color %)' : cannot convert parameter 1 from 'BSGameFramework::Graphics::Color ^' to 'const BSGameFramework::Graphics::Color %' c:\users\nicola\desktop\directx prove\bsgameframework\bsgame\Color.h 24 1 BSGame

PS: BYTE is defined in Defines.h as unsigned char

SOLVED:

I've changed the property as follow:

static property Color^ White
{
    Color^ get()
{
    Color ^white = gcnew Color(255, 255, 255);

    return white;
}
}
Was it helpful?

Solution

Change the property to:

static property Color^ White
{
  Color get()
  {
    Color ^white = gcnew Color(255, 255, 255);

    return white;
  }
}

or

static property Color White
{
  Color get()
  {
    return Color(255, 255, 255);
  }
}

OTHER TIPS

const doesn't make sense for managed type parameters. Change the constructor to:

Color(Color% color)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top