Click here to Skip to main content
13,829,750 members

C / C++ / MFC

 
AnswerRe: How can I initialize an array of structs where the array size is set at compile time? Pin
Jochen Arndt6-Apr-18 0:36
mveJochen Arndt6-Apr-18 0:36 
GeneralRe: How can I initialize an array of structs where the array size is set at compile time? Pin
arnold_w6-Apr-18 1:32
memberarnold_w6-Apr-18 1:32 
GeneralRe: How can I initialize an array of structs where the array size is set at compile time? Pin
Jochen Arndt6-Apr-18 2:13
mveJochen Arndt6-Apr-18 2:13 
AnswerRe: How can I initialize an array of structs where the array size is set at compile time? Pin
Joe Woodbury6-Apr-18 7:06
professionalJoe Woodbury6-Apr-18 7:06 
Questionwhy ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
Tarun Jha3-Apr-18 8:53
memberTarun Jha3-Apr-18 8:53 
AnswerRe: why ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
Victor Nijegorodov3-Apr-18 10:03
memberVictor Nijegorodov3-Apr-18 10:03 
AnswerRe: why ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
David Crow3-Apr-18 11:41
memberDavid Crow3-Apr-18 11:41 
AnswerRe: why ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
leon de boer3-Apr-18 14:48
memberleon de boer3-Apr-18 14:48 
To me you are sort of asking a strange question well outside the literal string part, so lets just check you understand some basics

First a string is class or if you want an object it has constructors, destructor and methods it isn't just an array of characters.
string - C++ Reference[^]
You can't remotely equate those two lines as anything similar, do you understand that?

So with a string class when you declare it as a const (like your commented out) what are you expecting it will do?
So you are clear you are asking for a constant pointer to an object and trying to set some literal string to that object.
This may also help understand Victors response and David deals with the literal part.

The point here is you can only create a string when it matches one of the constructor types of the class.
What constructor functions exist controls how you can create it.
Here is the examples of showing the seven standard constructor methods for the class
string::string - C++ Reference[^]

The situation with just a character array is very different
const char *ptr = "tarun";

We have a simple array of characters that can never be changed AKA they are constant

Everything from a C to a C++ compiler understands the later because it's very trivial.
In vino veritas


modified 3-Apr-18 23:11pm.

QuestionHelp compiling OpenCV Pin
_Flaviu3-Apr-18 0:25
member_Flaviu3-Apr-18 0:25 
AnswerRe: Help compiling OpenCV Pin
Victor Nijegorodov3-Apr-18 3:04
memberVictor Nijegorodov3-Apr-18 3:04 
GeneralRe: Help compiling OpenCV Pin
_Flaviu3-Apr-18 3:08
member_Flaviu3-Apr-18 3:08 
GeneralRe: Help compiling OpenCV Pin
_Flaviu3-Apr-18 3:08
member_Flaviu3-Apr-18 3:08 
GeneralRe: Help compiling OpenCV Pin
Victor Nijegorodov3-Apr-18 5:08
memberVictor Nijegorodov3-Apr-18 5:08 
AnswerRe: Help compiling OpenCV Pin
Jochen Arndt4-Apr-18 0:02
mveJochen Arndt4-Apr-18 0:02 
QuestionCreating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 1:53
memberTarun Jha2-Apr-18 1:53 
SuggestionRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 1:57
protectorRichard MacCutchan2-Apr-18 1:57 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 1:59
memberTarun Jha2-Apr-18 1:59 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 2:10
protectorRichard MacCutchan2-Apr-18 2:10 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 3:32
memberTarun Jha2-Apr-18 3:32 
AnswerRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 2:19
protectorRichard MacCutchan2-Apr-18 2:19 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 2:19
memberTarun Jha2-Apr-18 2:19 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 2:26
protectorRichard MacCutchan2-Apr-18 2:26 
QuestionIs it possible to link a DLL in another DLL and call its functions? Pin
manoharbalu2-Apr-18 1:29
membermanoharbalu2-Apr-18 1:29 
AnswerRe: Is it possible to link a DLL in another DLL and call its functions? Pin
Richard MacCutchan2-Apr-18 1:59
protectorRichard MacCutchan2-Apr-18 1:59 
QuestionMFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
janaswamy uday30-Mar-18 3:34
memberjanaswamy uday30-Mar-18 3:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190114.1 | Last Updated 16 Jan 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid