V. M.
V. M.

Reputation: 65

How to condense a struct in a class c++?

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;
}

Upvotes: 0

Views: 64

Answers (1)

kenash0625
kenash0625

Reputation: 697

what about this one

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

typedef struct d::a da;

Upvotes: 1

Related Questions