cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Polimorphic function
Polimorphic function
Nov 14, 2012 at 1:19pm UTC
Kostya Khuta
(5)
Hi! I need to create Polimorphic function which takes abstract class as argument.
class Abstract{ //Абстрактный класс
public:virtual void print_msg()=0;
};
Nov 14, 2012 at 1:21pm UTC
Peter87
(11234)
What is the problem?
Nov 14, 2012 at 1:24pm UTC
Kostya Khuta
(5)
i don't know how it made.
for exemple:
class Abstract{ //Абстрактный класс
public:virtual void print_msg()=0;
};
class A:public Abstract{
void_print_msg()
{
cout<<"Hello";
}
};
int main()
{
Here we mast create ibject of class A and for him we need to call polimorphic function..
}
Nov 14, 2012 at 1:28pm UTC
kbw
(9488)
1
2
3
4
void
print(Abstract* ) {
// do something
}
Nov 14, 2012 at 1:46pm UTC
Kostya Khuta
(5)
ok.. i made it
void print(Abstract* )
{
cout<<"Polimorphic function";
}
but how i can call it in main??
int main()
{
A a();
//I can't create object of abstract class and it is error if i write "print(a)"
}
Nov 14, 2012 at 1:49pm UTC
Kostya Khuta
(5)
i understood. it is my bag=)
i must write print(&a)
Thank you!
Topic archived. No new replies allowed.