Compiling error

C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(116) : error C2662: 'int TArray<FString,FDefaultAllocator>::Emplace<const FString&>(const FString &)': cannot convert 'this' pointer from 'const TArray<FString,FDefaultAllocator>' to 'TArray<FString,FDefaultAllocator> &'

C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(116): note: Conversion loses qualifiers

C:\Users\stefan\Documents\UE_4.27\Engine\Source\Runtime\Core\Public\Containers/Array.h(1956): note: see declaration of 'TArray<FString,FDefaultAllocator>::Emplace'

/
|
Unreal Error log

/
|
Code

For context I did the compiling time optimization thing

/
|
Code in course

You made ValidWords a member variable which you are modifying in GetValidWords which means that can’t be a const member function.

thanks I will make sure to read the rest of the const thing

   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(111) : error C2511: 'TArray<FString,FDefaultAllocator> UBullCowCartridge::GetValidWords(TArray<FString,FDefaultAllocator>)': overloaded member function not found in 'UBullCowCartridge'
  C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.h(10): note: see declaration of 'UBullCowCartridge'
   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(112) : error C2065: 'WordList': undeclared identifier
   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(114) : error C2597: illegal reference to non-static member 'UBullCowCartridge::Words'
   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(114) : error C3867: 'UBullCowCartridge::Words': non-standard syntax; use '&' to create a pointer to member
   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(114) : error C2109: subscript requires array or pointer type
   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(116) : error C2597: illegal reference to non-static member 'UBullCowCartridge::Words'
   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(116) : error C3867: 'UBullCowCartridge::Words': non-standard syntax; use '&' to create a pointer to member
   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(116) : error C2109: subscript requires array or pointer type
   C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(119) : error C2597: illegal reference to non-static member 'UBullCowCartridge::ValidWords'
  C:\Users\stefan\Documents\UE Games\Unreal Engine C++ Course\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.h(29): note: see declaration of 'UBullCowCartridge::ValidWords'


I’m confused here.

error C2511: ‘TArray<FString,FDefaultAllocator> UBullCowCartridge::GetValidWords(TArray<FString,FDefaultAllocator>)’: overloaded member function not found in ‘UBullCowCartridge’

Your class definition has the following member function declared

TArray<FString> GetValidWords(TArray<FString>) const

But you have defined

TArray<FString> GetValidWords(TArray<FString>)

Thanks King :crown:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.