How should I declare a variable with the "string" data type?

I would like to declare a variable and initialize it with some string data. I found two methods online, but I am unsure of the best method.

Method 1 - Works but produces errors during compilation

string TestString = “This is a test string.”;

Method 2 - Works but seems odd to me that I have to use std namespace

std::string TestString = “This is a test string.”;

Thanks!

  • Anthony

A little confused by this statement.

There isn’t a built-in string type in C++. If you’re using Unreal you should use their string type FString, otherwise std::string.

Thanks!

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

Privacy & Terms