类对结构的访问权限
Access of class to struct
为了对点M(x,y)
执行应用操作,我定义了一个类POINT2D.h
:
#ifndef POINT2D_H_INCLUDED
#define POINT2D_H_INCLUDED
class POINT2D {
POINT2D (); //first constructor
POINT2D(double x,double y); // second constructor
private:
Point M, PointImage;
public:
void DeclarerM(){
std::cout << "Entrer les composantes du point M : " << " ";
std::cin >> M.x >> M.y;
}
Point Trnaslation(Point M); //Functions applied on Point
Point Rotation(Point M);
Point SymetrieAxiale (Point M);
Point Homothetie(Point M);
};
#endif // POINT2D_H_INCLUDED
和一个结构体CCD_ 3:
struct Point{ //structure Point
double x; //the coordinates of the Point
double y;
};
当我运行它时,我在类中得到一个错误,说"Point没有命名类型"。问题出在哪里?
在C++中,在使用类型之前,必须声明或定义它。因此,由于POINT2D
不知道您在main.cpp中声明的Point
结构,因此您无法使用它。您可以转发声明Point
,也可以将Point
移动到其自己的头文件中,然后将其包含在POINT2D.h
和main
中。
POINT2D
也有问题,因为您的构造函数都是私有的。您应该在它们之前添加public:
,或者将它们移到类中已经存在的public
部分中。
相关文章:
- 编写一个函数来删除单链表中的节点(尾部除外),仅授予对该节点的访问权限
- 为什么我在空指针错误(链表)中获取成员访问权限
- 为什么"delete"操作员给我访问权限冲突
- 从根权限进程创建可访问的文件
- 父级的子属性 - 访问权限
- 从C++获得对在python中创建的C++类的访问权限
- 威纳派读取自定义文件或文件夹的所有访问权限
- 授予另一个类对特定方法的访问权限
- 链接 boost 库时"Error while loading shared libraries"引发的,除了我无法使用 root 访问权限来修复它
- 正确的友元定义,以授予 std::map 对私有默认构造函数的访问权限
- TOCTTOU - 在处理文件之前使用访问权限
- 如何通过指针仅向结构的某些成员提供可变访问权限
- main() 对连续运行的线程中的编辑值具有只读访问权限 - C++
- 如何使用 c++ 创建对"everyone"具有共享访问权限的文件夹
- 嵌套类嵌套类的访问权限
- 为什么继承的受保护操作员=()有公共访问权限
- Lambda 函数,用于调用有权访问类成员的成员函数
- 为什么拥有不同访问控制权限的成员的工会不是标准布局
- 获取从基类指针到具有不同类型的两个派生成员变量的访问权
- 拒绝访问nt权限本地服务