Seok Lee blog

C++ practice

I try to collect C++ syntax while I am practicing Unreal C++ implementation.

#include <iostream>

int main()
{
    int num = 342;
    std::cout<<"num = "<<num<<"\n";
    std::cout<<"address of num is at &num = "<< &num<<"\n";
    return 0;
}
num = 342
address of num is at &num = 0x7ffd2a738f6c
#include <iostream>
int main()
{
    int num = 32;
    int * pointerTonum = &num;
    std::cout<<"pointerTonum stores the address of num as"<< pointerTonum<<endl;
    std::cout<<"the address of PointerTonum stores the value of num as<< *pointerTonum<<endl;
}
class ENGINE_API USphereComponent : public UShapeComponent
{
    // code
}
#include <iostream>
using namespace std;
class printNum{
    public:
        void print(int i){
            cout<<"print integer: "<< i <<endl;
        }
        void print(double f){
            cout<<"print float: "<< f <<endl;
        }
        void print(char*c){
            cout<<"print character: "<< c <<endl;
        }

}

int main()
{
    printNum pn;

    // print integer
    pn.print(23);
    // print float
    pn.print(234.23);
    // print character
    pn.print("hello C++");

    return 0;
}
void AFPSObjectiveActor::NotifyActorBeginOverlap(AActor* OtherActor)
{
	Super::NotifyActorBeginOverlap(OtherActor);
	PlayEffects();

	AFPSCharacter* MyCharacter = Cast<AFPSCharacter>(OtherActor);
	if (MyCharacter)
	{
		MyCharacter->bIsCarryingObjective = true;
	}

}
class UBoxComponent; // forward declaration
class FPSGAME_API AFPSExtractionZone : Public AActor
{
protected:
	UBoxComponent* OverlapComp;
}
#include <iostream>
using namespace std;
int main()
{
	float f = 5.4;
	int a = static_cast<int>(f);
	cout <<a;
}
  Pointers References
what is stored memory address memory address
can be re-assigned Yes No
Can be null Yes (use nullptr) No, must be initialized
Accessing contents * ActorPtr ActorRef
Accessing address ActorPtr &ActorRef
Changing the address ActorPtr = &Actor Not allowed
Changing the value * ActorPtr = Actor ActorRef = Actor
Lefthand side item Accessor Examples Remark
Instance or reference . mygrab.grab() access to member function (grab()) of mygrab class
pointer -> mybrabptr->grab()  
class enum.namespace :: ugrabber::grb