468,512 Members | 948 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

function call without creating object

in C++ you can call function / methods without creating an object of
that Class?

like the the following, it calls Update() + Draw() functions by Class
name CInterfaceGroup + CContainer.

In Java, one can only call method by Class name if it is static
method.

In C++, you can call any function without creating an Object like -
CContainer * cc = new CContainer;
cc->Draw();

=========================

CGraphicsGroup::~CGraphicsGroup() {
}

void CGraphicsGroup::Create() {

}

void CGraphicsGroup::Update() {
CInterfaceGroup::Update();
}

void CGraphicsGroup::Draw() {
CContainer::Draw();
}
Mar 13 '08 #1
1 3137
Laharl
849 Expert 512MB
Using new creates an object; it returns a pointer to the created object. The -> operator is like the . operator when working with pointers. You can make static methods in C++ the same way you can in Java, and they are called the same way. Read here for more information.
Mar 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Falc2199 | last post: by
6 posts views Thread by Davinci_Jeremie | last post: by
10 posts views Thread by bienwell | last post: by
9 posts views Thread by Morten Lemvigh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.