| Battle_Arena Game ~/Desktop/Battle_Aren 1 | cmake-build-debug | PlayerApplications A CMakeLists.txt 2 main.cpp ulı External Libraries O Scratches and Consoles #include "PlayerApplications.h" 2 using namespace std; 3. 4. PlayerApplications::PlayerApplications() { Username = ""; 6 password =

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In C++, what is a const char*? And when using const char* would this be well suited or just using string&?

As well as why do I get an error when I try having the username has const char, but I do not get an error when making const char username into a const char* username? What is the reason for this error I am getting?

17
class PlayerApplications {
18
Potected:
const char username;
19
20
const char *password;
21
static int generate_ID; // Generating users id's
22
unordered_map<string, int> usersID;
23
unordered_map<string, string> players_information;
24
public:
25 5
PlayerApplications();
PlayerApplications(string & username);
26
27
28
void create account ();
29
30
31
void choose factions ();
32
33
34
Transcribed Image Text:17 class PlayerApplications { 18 Potected: const char username; 19 20 const char *password; 21 static int generate_ID; // Generating users id's 22 unordered_map<string, int> usersID; 23 unordered_map<string, string> players_information; 24 public: 25 5 PlayerApplications(); PlayerApplications(string & username); 26 27 28 void create account (); 29 30 31 void choose factions (); 32 33 34
| Battle_Arena_Game ~/Desktop/Battle_Aren 1
| cmake-build-debug
#include "PlayerApplications.h"
using namespace std;
PlayerApplications
3.
CMakeLists.txt
4 5
PlayerApplications::PlayerApplications() {
2 main.cpp
> ullıi External Libraries
username = "";
C+
password = "".
Scratches and Consoles
7
. Structure
I Proje
Transcribed Image Text:| Battle_Arena_Game ~/Desktop/Battle_Aren 1 | cmake-build-debug #include "PlayerApplications.h" using namespace std; PlayerApplications 3. CMakeLists.txt 4 5 PlayerApplications::PlayerApplications() { 2 main.cpp > ullıi External Libraries username = ""; C+ password = "". Scratches and Consoles 7 . Structure I Proje
Expert Solution
Step 1

The use of const char* in C++

const char *p - This is a pointer to a constant character. You cannot change the value pointed by p, but you can change the pointer p itself.

In C++, we can use strings as constant array of characters that is why we use const keyword before char*.

const char *username:  We cannot modify the string at later stage in program. We can change username to point something else but cannot change value present at username.

In  your program context it is well suited to use const char *username.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education