'C++ E0147 declaration is incompatible with static object

Websource.hpp

#ifndef WEBSOURCE_HPP
#define WEBSOURCE_HPP
#pragma once

class Colour
{
public:
    unsigned char _ucRed;
    unsigned char _ucGreen;
    unsigned char _ucBlue;
    Colour(unsigned char i_red, unsigned char i_green, unsigned char i_blue);
    Colour(Colour& c);
    Colour();
    void setColour(unsigned char i_red, unsigned char i_green, unsigned char i_blue);
};

Colour::Colour(unsigned char i_red, unsigned char i_green, unsigned char i_blue)
{
    this->setColour(i_red, i_green, i_blue);
}

Colour::Colour(Colour& c)
{
    this->setColour(c._ucRed, c._ucGreen, c._ucBlue);
}

Colour::Colour()
{
    this->setColour((unsigned char)0, (unsigned char)0, (unsigned char)0);
}

void Colour::setColour(unsigned char i_red, unsigned char i_green, unsigned char i_blue)
{
    this->_ucRed = i_red;
    this->_ucGreen = i_green;
    this->_ucBlue = i_blue;
}

#endif

Website.hpp

#ifndef WEBSITE_HPP
#define WEBSITE_HPP
#pragma once

#include "Websource.hpp"

template <typename T, int N = 16>
class Page {
public:
    static Colour c_logo;   // logo colour
};

Colour website::Page<double>::Page::c_logo();

#endif

This code leads to Error 0147.

Severity Code Description Project File Line Suppression State Error (active) E0147 declaration is incompatible with "Colour website::Page::c_logo [with T=double, N=16]" (declared at line 31 of "c:\Users\hasler\Documents\ga_design\Website.hpp") ga_design c:\Users\hasler\Documents\ga_design\Website.hpp 88

However, using another constructor works like a charm:

Colour website::Page<double>::Page::c_logo(0,0,0);

And I'm here struggling to understand why one constructor would work and another wouldn't.



Solution 1:[1]

To mark the question as answered: "It's a case of the most vexing parse in C++. Using Colour website::Page::Page::c_logo; will work." – R Sahu

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hasleron