C 的间接水平与众不同

c++ differs in levels of indirection from

本文关键字:水平 与众不同      更新时间:2023-10-16

我在尝试编译时收到了此错误消息:

  • 错误c2556:'int *gent(const binaryBuffer&,const engryptightekekey&(':Overloaded函数仅通过'BinaryBuffer Encrypt(const binarybuffer&const binarybuffer&const const encryptionkeykeykey& amp; amp; amp; amp;('

  • 错误c2040:'encrypt':'int *(const binaryBuffer&,const engryptightekekey&('间接水平与'binarybuffer(const binarybuffer&amp&amp&amp&amp const const encyptionKey&('

  • 错误c2556:'char *decrypt(const binaryBuffer&,const engryptightekekey&(':Overloaded函数仅通过'BinaryBuffer decrypt(const binaryBuffer&const binarybuffer&const const const fencryptionkeykeykey& amp; amp; amp;('

  • 错误c2040:'解密':'char *(const binaryBuffer&,const engryptionKey&('间接级别与'binarybuffer(const binarybuffer&amp&amp&amp&amp&amp const const encyptionKey&('

CPP文件:

#include "Encryption.h"
#include <algorithm>
#include <iterator>
#pragma intrinsic(_rotl8, _rotr8)
constexpr auto xorKeyLocation = 0;
constexpr auto numberOfBitsToRotateLocation = 1;
int* Encrypt(const BinaryBuffer& plainText, const EncryptionKey& key)
{
    const auto xorKey = key[xorKeyLocation];
    const auto numberOfBitsToRotate() = key[numberOfBitsToRotateLocation];
    const BinaryBuffer result;
    do
    {
        std::transform(
            plainText.begin(),
            plainText.end(),
            std::back_inserter(result),
            [&](const auto byte)
        {
            const auto xored = byte ^ xorKey;
            const auto shifted = _rotl8(xored, numberOfBitsToRotate);
            return shifted;
        });
    } while (0);
    return result;
}
char* Decrypt(const BinaryBuffer& cipherText, const EncryptionKey& key)
{
    const auto xorKey = key[xorKeyLocation];
    const auto numberOfBitsToRotate() = key[(std::vector<int>)numberOfBitsToRotateLocation];
    const BinaryBuffer result;
    std::transform(
        cipherText.cbegin(),
        cipherText.cend(),
        std::back_inserter(result),
        [&](const auto byte)
    {
        const auto shifted = _rotr8(byte, numberOfBitsToRotate);
        const auto xored = shifted ^ xorKey;
        return xored;
    });
    return result;
}

h文件:

#pragma once
#include "Common.h"
BinaryBuffer Encrypt(const BinaryBuffer& plainText, const EncryptionKey& key);
BinaryBuffer Decrypt(const BinaryBuffer& cipherText, const EncryptionKey& key);

我在做什么错?

谢谢。

函数的返回类型与标题中的声明不符。