Structs and classes
Nov 9, 2017 at 1:19am UTC
I wish to define a return value for a member function to be a struct defined within the class, however I do not want to use the class in the return value.
For example I currently have to do this:
ClassA::myStruct ClassA::f() { ... }
I want to do this:
myStruct ClassA::f() { ... }
Is this possible? If so, how do i do it?
Cheers!
-Caolan
Nov 9, 2017 at 1:51am UTC
> I do not want to use the class in the return value.
¿why not?
the name of your struct is ClassA::myStruct
Nov 9, 2017 at 1:51am UTC
Use an alias:
1 2 3 4 5 6 7 8
struct A {
struct B {};
B f();
};
// Alias B as the nested class name A::B
using B = A::B;
B A::f() { return {}; }
Topic archived. No new replies allowed.