// c_enum.h
#pragma once
typedef enum { val1 = 0 } c_style_enum_t;
c_style_enum_t c_func();
< /code>
// my_class.hpp
#pragma once
extern "С" {
#include "c_enum.h"
}
class my_class {
public:
private:
friend c_style_enum_t ::c_func();
};
< /code>
gcc напечатает ошибку: < /p>
error: 'enum c_style_enum ' is not a class or namespace
142 | friend c_style_enum ::c_func();
error: ISO C++ forbids declaration of 'c_func' with no type [-fpermissive]
Когда возвращается тип c_func () int или что -то другое, кроме как перечисление типа этого Wokrs
Как сделать эту работу?
class my_class { public: private: friend c_style_enum_t ::c_func(); }; < /code> gcc напечатает ошибку: < /p> error: 'enum c_style_enum ' is not a class or namespace 142 | friend c_style_enum ::c_func(); error: ISO C++ forbids declaration of 'c_func' with no type [-fpermissive] [/code] Когда возвращается тип c_func () int или что -то другое, кроме как перечисление типа этого Wokrs Как сделать эту работу?