Jump to content

Recommended Posts

Posted

to go into but more explanation of what question I am asking is, why does

&World::Clear; 

 

work instead of

World::Clear;

Intelleasense said to put a & in front but why does it not work without a & symbol?

OS: Windows 10 Pro

CPU:  i3-10100 CPU @ 3.60GHz
GPU: NVIDIA 2060 Super - 8 GB

RAM: 32 GB

Posted

Neither of them will work.

 

First of all you have to have an instance of the world

and then use the methods (functions) on that instance

 

World* myWorld = World::Create();
myWorld->Clear();

 

Intellasense does some strange stuff some times. :/

OS: Windows 10 Pro

CPU:  i3-10100 CPU @ 3.60GHz
GPU: NVIDIA 2060 Super - 8 GB

RAM: 32 GB

Posted

& (ampersand if you want to google it ;) ) has 2 functions in C++

  1. When used during declaration of a variable it means said variable is a reference - that is any change made to it is made to the original also;
  2. When used infront of an existing variable it takes the address of the object ( effectively turning it into a pointer )

  • Upvote 1

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Posted

& (ampersand if you want to google it wink.png ) has 2 functions in C++

  1. When used during declaration of a variable it means said variable is a reference - that is any change made to it is made to the original also;
     
  2. When used infront of an existing variable it takes the address of the object ( effectively turning it into a pointer )

 

 

ah ok

 

You might also want to read up on C++ pointers.

http://www.cplusplus.com/doc/tutorial/pointers/

 

whoa, that is a ton of info on pointer's xD (also btw I did

 world->Clear();

first but then intellesense wanted me to put &World::Clear; instead, Clearly I know that wasn't correct.)

OS: Windows 10 Pro

CPU:  i3-10100 CPU @ 3.60GHz
GPU: NVIDIA 2060 Super - 8 GB

RAM: 32 GB

Posted

I did

 world->Clear();

first but then intellesense wanted me to put &World::Clear; instead, Clearly I know that wasn't correct.

 

It suggests that you either accidentally used uppercase for world (World) or that the variable "world" was not in scope.

  • Upvote 1

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Posted

It suggests that you either accidentally used uppercase for world (World) or that the variable "world" was not in scope.

Yea I used World instead, anyways though thanks for the cool info Guppy as usual wink.png

OS: Windows 10 Pro

CPU:  i3-10100 CPU @ 3.60GHz
GPU: NVIDIA 2060 Super - 8 GB

RAM: 32 GB

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...