#How do I reference an int that is defined in class x, in class y.

17 messages · Page 1 of 1 (latest)

worthy fableBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

hard eagle
#

Send the actual code and error

#

First error in the list anyways

devout jacinth
#

It's source engine btw

cunning mirage
devout jacinth
#

nope

#

where would I have to put int& anyway

#

or int* = nullptr

#

into the declaration of the int or the reference from another class

cunning mirage
#

the reference from the other class

#

anyway show code please!

devout jacinth
#

I am doing the reference in the function if that helps

#

I just wan't to add 1 to the int everytime the function is called. And the int is in the other class than the function

hard eagle
#

You still haven't shared any code

#

Make a small example that reproduces the problem

devout jacinth
# hard eagle Make a small example that reproduces the problem

filefromclass1.h

Class 1 : public base
{
public:
  int xyz = 0
};

filefromclass2.cpp

#include "filefromclass1.h"
#include "filefromclass2.h"
#include "base.h"

void class2::create(void)
{
  xyz = xyz + 1;
  
  some other code here
}

And yeah. Idk how to make that thing in class 2 work