Reputation: 83
I have 2 classes, Class A
class A {
static void one() {
print('One');
}
}
and Class B
class B {
static void two() {
print('Two');
}
}
I want to access the static members of these classes from a third Class C
class C {
// Todo
}
What operations can I do to achieve this?
void main() {
C.one(); // 'One'
C.two(); // 'Two'
}
I want to access the static members of classes A and B from class C without creating the object of the class.
Upvotes: 1
Views: 1134
Reputation: 325
Try creating static methods to access the static members of class A and B
class C {
static void one() {
A.one();
}
static void two() {
B.two();
}
}
Upvotes: 1