表达式必须具有类类型

Expression must have class type

本文关键字:类型 表达式      更新时间:2023-10-16

我假设这与指针有关,但这是我的代码有错误。显然我还没有完成,但错误出在下面代码中的键上。

bool LCR_cipher::iskeysOK()
{
    vector<char> v(keys.begin(), keys.end());
    std::transform(v[0].begin(), v[0].end(), v[0].begin(), ::tolower);
}

这是头文件

class LCR_cipher
{
public:
    // Constructor:
    LCR_cipher(char *context_string, char *keys_string);
    // Destructor: deallocate memory that was allocated dynamically
    ~LCR_cipher();
    //check whether *keys string has valid LCR encryption value
    bool iskeysOK();
    //encrypt context string
    void encryption();
    //unencrypt context string (optional)
    void unencryption();
    //check whether the context string is encrypted or not
    bool isencrypted();
    //Retrieve CLR encryption value from *keys string
    void getkeys(int& a, int& c);
    // output the *context to console
    void output_context();
private:
    char *context; //array to store context string
    char *keys; //array to store encryption keys
    bool encrypted; //whether string in *context is encrypted or not
    int context_MaxSize;
    int context_CurrentSize;
    int keys_MaxSize;
    int keys_CurrentSize;

}

我哪里出错了?

在这里:

  v[0].begin()
v

是 char 的向量,所以 v[0] 是 char,char 没有方法。

相关文章: