Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How can i use in A class value, to B class in C++


 class A
     float Aspeed;


     Aspeed = 10.f;   



 class B
     float Bspeed;       


     Bspeed =    [ i want to get Aspeed of class A      ]   <- What do i write ????

i want connect two different class.

i can't see example.

could you make simple easy example ?? please....

Product Version: UE 4.12
more ▼

asked Sep 23 '16 at 08:24 AM in C++ Programming

avatar image

1 1 1

avatar image fabianu Sep 23 '16 at 09:58 AM

There are multiple possible solutions. What do you want to achieve? Then i can give you a better tip.

avatar image psr1331 Sep 26 '16 at 12:23 AM

dear fabianu


i want to get member value of other class.

That class is not parent and child.

i need general example......

connect different other class!!

i'm sorry.. my question range is so large TT_TT

avatar image psr1331 Sep 26 '16 at 12:44 AM

for example

in class A

UStaticMeshComponent* AAA = CreateDefaulSubobject

in class B

I want use value of AAA!!

How to connect???

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Hey psr1331-

Inside the .h for class be you will first need to add an include statement for Class A. Once you've done this you can create a variable inside Class B who's type is of Class A (which would look like A MyClassARef). From this variable, as HuntaKiller mentioned, you can then get the specific atribute of class A that you need. In the case of your example it would be BSpeed = MyClassARef.ASpeed. For this to work, ASpeed needs to be declared public inside Class A so that another class can see/use it.


Doug Wilson

more ▼

answered Sep 27 '16 at 02:16 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You need to instantiate class A within class B then access the variable you declared. Bspeed = A.Aspeed;

This is a basic function of any programming language, and not to be discouraging but you won't be able to do much in C++ without that basic knowledge. Try sticking to blueprints, which for you should not have any disadvantages compared to trying to do it in C++. There are many UE4 tutorials on YouTube.

more ▼

answered Sep 26 '16 at 06:27 PM

avatar image

160 10 12 19

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

This should work:

 TSubclassOf<A> asd = A::StaticClass();
 Bspeed = asd.GetDefaultObject()->Aspeed;
more ▼

answered Sep 27 '16 at 12:42 PM

avatar image

106 2 4 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question