Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Class method returns an enum declared in the class . (COMPILATION ERROR)
Forum Updated to NodeBB v4.3 + New Features

Class method returns an enum declared in the class . (COMPILATION ERROR)

Scheduled Pinned Locked Moved Solved Language Bindings
3 Posts 2 Posters 530 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    G-HB
    wrote on last edited by
    #1

    Hi,

    I have defined an enum inside a class. The I would want to implement a class method that returns a value of this enum.
    I´m pretty sure that I am doing something incorrectly. Please , can you help me?

    (Code: simplifing a big class A)

    class A : public B
    {
    Q_OBJECT
    public:
    enum DcConnectorIdx
    {
    DC_CONN_1,
    DC_CONN_2,
    DC_CONN_3,
    DC_CONN_4,
    DC_CONN_5,
    DC_CONN_6,
    DC_CONN_7,
    DC_CONN_8
    };
    Q_ENUM(DcConnectorIdx)

        /*
           A lot of pubic methods not related to the problem......
       */
    protected:
           DcConnectorIdx getSatelliteId(SatelliteId satelliteId);
    

    };

    Issue rported by compiler is:


    error: ‘DcConnectorIdx’ does not name a type 2258 | DcConnectorIdx A::getSatelliteId(SatelliteId satelliteId)

    Thanks in advance !!!

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by sierdzio
      #2

      In your cpp file, you need to add class name there:

      A::DcConnectorIdx A::getSatelliteId(SatelliteId satelliteId)
      {
        // implementation
      }
      

      (Z(:^

      G 1 Reply Last reply
      3
      • sierdzioS sierdzio

        In your cpp file, you need to add class name there:

        A::DcConnectorIdx A::getSatelliteId(SatelliteId satelliteId)
        {
          // implementation
        }
        
        G Offline
        G Offline
        G-HB
        wrote on last edited by
        #3

        @sierdzio Thank you very much for your quick answer!!! I have done this change and it works!!!
        Thanks!!!!!
        Have a good day,

        1 Reply Last reply
        0
        • SGaistS SGaist has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved