Implementing ERC2981.sol in an ERC721 contract

Hey folks,

I'm learning and experimenting with NFT royalties, for example, something like this:

    // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "";
import "";
import "";

contract MyToken is ERC721, Ownable, ERC2981 {
    constructor() ERC721("MyToken", "MTK") {}

    function safeMint(address to, uint256 tokenId) public onlyOwner {
        _safeMint(to, tokenId);

this does not work though, I get:

Derived contract must override function "supportsInterface". Two or more base classes define function with same name and parameter types.

What would that function look like?


There is an implementation of ERC2981 on a ERC721, in there you can see that you would just need to override it like this:

 * @dev See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC2981) returns (bool) {
    return super.supportsInterface(interfaceId);

oh great!
How did I miss that? lol