gpt4 book ai didi

c++ - '->C' 的左侧必须指向类/结构/union/通用类型

转载 作者:行者123 更新时间:2023-11-30 05:14:43 25 4
gpt4 key购买 nike

<分区>

这个文件只包含这个类的声明。

测试.h

class Test
{
private:
Types::A a;
B bb; // B stands for class B { // some objects;};
C cc; // C "
D dd; // D "
CString str;
public:
Test();

void getADetails();
int getBDetails();
void getCDetails();
void getDDetails();

};

此文件包含所有 API 的定义。

测试.cpp

在构造函数中,我们使用对象 bb 的成员初始化器

    Test::Test() :bb(Log) // bb constr expects a static log func, all other constrs doesn't contain any parameters 
{

}
int Test::getCDetails()
{
this->cc.getDetails(this->str, this->A);
return 0;
}

此文件包含用于创建该类对象的测试用例。

测试用例.cpp

    TEST_METHOD(test_App)
{
Test t;
t.getCDetails();
t.getBDetails();
}

当我尝试编译代码时,出现编译时错误。请跟踪以下内容:

Error 26 error C2227: left of '->B' must point to class/struct/union/generic type
Error 28 error C2227: left of '->C' must point to class/struct/union/generic type

谁能解释一下,因为我是 c++ 的新手。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com