Home > Mobile >  How to condense a struct in a class c ?
How to condense a struct in a class c ?

Time:09-30

I have a a.h which has a class d. I am wondering how to make a shorthand way to use the struct 'a' inside of my class.

//a.h
class d
{
    public:
    struct a
    {
      int val;
    }
};


//a.cpp
#include "a.h"
using d::a;         //line with error
a methodName()
{
  //does stuff
  return object_of_type_a;
}

CodePudding user response:

what about this one

class d
{
public:
    struct a
    {
        int val;
    };
};

typedef struct d::a da;
  •  Tags:  
  • c
  • Related