How to call void from another file?

How can i call this from inside of another file?
Can you tell me what is wrong? I'm beginner and i have no enough information.
After I include ".h" file, i tried a few options to call this.
I hope, you will answer as soon as possible by the permission of ALLAH.
This is example ".h" file:

Code: Select all

#include "Player.h"
#include "GameCVars.h"
#include "GameActions.h"

#include <CryEntitySystem/IEntitySystem.h>

#include "LocalPlayerComponent.h"
class CGameFlashlight
   void ToggleFlashlight() const;

This is example ".cpp" file:

Code: Select all

#include "gameflashlight.h"
void CGameFlashlight::ToggleFlashlight() const
{ CryLogAlways("1"); }

Re: How to call void from another file?

If I understood you correctly you want to know how to call the class function from somewhere else. Okay so since you have created a CGameFlashlight class you have to instantiate this class somewhere else now. For my example I will use an imaginary player class.
Player.cpp which is somewhere else in your code:

Code: Select all

#include "GameFlashlight.h" //include the header of your Flashlight class since you want to use it now.

// Some random function inside the player
void CPlayer::PlayerUpdate()
   CGameFlashlight flashLight; // This is your class object now, but this object will only exists in this function call and will be gone after the functions ends.
   flashLight.ToggleFlashlight(); // Now we can call the function.

This is how you could do it. But there so much more stuff I would have to explain you and I would honestly recommend to look into some C++ resources and learn some of the basics, since it's important to at least understand the fundamental concept of C++.
Some Resources:


Who is online

Users browsing this forum: No registered users and 1 guest