-
November 12th, 2011, 04:35 PM
#1
What depa is this ?
I have a pattern question
Code:
class A
{
public:
T a1;
T a2;
void funcA()
{
//Initialize a1,a2
}
};
class B
{
public:
T a1;
void Do_a1(){}
};
class C
{
public:
T a2;
void Do_a2(){}
};
// in main
A a;
a.funcA();
//assign a1, a2 of A for B's a1 and C's a2
//then call Do_a1, Do_a2;
THat is the idea, and I'd like to know what pa is most same as it. Thanks a lot for help
Pumpobee is prolounced as mumbolee
-
November 17th, 2011, 03:22 AM
#2
Re: What depa is this ?
I don't follow what you are asking.
What is pa?
What exactly you want to do?
-
November 17th, 2011, 03:49 AM
#3
-
November 17th, 2011, 10:34 AM
#4
Re: What depa is this ?
I guess, from the context, depa means design pattern. Never heard this abbreviation before, though...
-
November 17th, 2011, 11:33 AM
#5
Re: What depa is this ?
I don't see any design pattern in that piece of code.
The classes A, B, and C are completely separated.
-
November 18th, 2011, 04:09 AM
#6
Re: What depa is this ?
Something like this: (though it's not a pattern )
Code:
template <typename T>
class A
{
public:
void funcA1()
{
T* pThis = static_cast<T*>(this);
//Initialize a1
//pThis->a1 something...
}
void funcA2()
{
T* pThis = static_cast<T*>(this);
//Initialize a2
//pThis->a2 something...
}
};
class T
{
public:
T() {}
};
class B: public A<B>
{
public:
T a1;
void Do_a1(){}
};
class C: public A<C>
{
public:
T a2;
void Do_a2(){}
};
int main()
{
// in main
//assign a1, a2 of A for B's a1 and C's a2
//then call Do_a1, Do_a2;
B b;
b.funcA1();
b.Do_a1();
C c;
c.funcA2();
c.Do_a2();
return 0;
}
Last edited by Igor Vartanov; November 18th, 2011 at 04:14 AM.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|