Click here to Skip to main content
15,914,795 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C++ - how to refer a header file which is used in a dll while loading thru loadlibrary method Pin
Hans Dietrich7-Feb-11 2:07
mentorHans Dietrich7-Feb-11 2:07 
AnswerRe: C++ - how to refer a header file which is used in a dll while loading thru loadlibrary method Pin
CPallini7-Feb-11 3:00
mveCPallini7-Feb-11 3:00 
AnswerRe: C++ - how to refer a header file which is used in a dll while loading thru loadlibrary method Pin
Stefan_Lang8-Feb-11 1:36
Stefan_Lang8-Feb-11 1:36 
Question"Could not find field 'Description'" error in access database. Pin
Le@rner7-Feb-11 1:21
Le@rner7-Feb-11 1:21 
AnswerRe: "Could not find field 'Description'" error in access database. Pin
David Crow7-Feb-11 8:47
David Crow7-Feb-11 8:47 
QuestionProblem using const float ** Pin
Alex80gbg6-Feb-11 22:41
Alex80gbg6-Feb-11 22:41 
AnswerRe: Problem using const float ** Pin
Stefan_Lang6-Feb-11 23:18
Stefan_Lang6-Feb-11 23:18 
AnswerRe: Problem using const float ** Pin
Andrew Brock6-Feb-11 23:41
Andrew Brock6-Feb-11 23:41 
const doesnt work as you expect. Sorry Smile | :) .
const will only affect the access to 1 thing, depending on where it is depends on what it affects.

const char *szMsg = "hello world";
szMsg = "hello back"; is valid
szMsg[0] = 'H'; is invalid
This const will stop you changing the contents of the string "hello world", however it will not stop you changing the value of the pointer szMsg.

char const *szMsg = "hello world";
This is the same as the previous const char *szMsg = "hello world";
This is very uncommon and usually provides no use. What a function does with its pointers is its business. As long as it doesn't change your data you don't care.

char *const szMsg = "hello world";
szMsg = "hello back"; is invalid
szMsg[0] = 'H'; is valid
This makes the value of the pointer szMsg constant, but not the data pointed to

Combining the 2
const char *const szMsg = "hello world";
szMsg = "hello back"; is invalid
szMsg[0] = 'H'; is invalid
This makes everything constant.


What does this mean for you?
This means that your constant 2D array can be changed.
You are only protecting the bottom level pointer, which means you cannot change the values pointed to by the 2nd dimension of the array (the floats).
You are not protecting the 2D array itself. The location at which the array is located and the 2nd dimension of the array can be changed at will.
const char *szMsgs1[] = { "hello", "world" };
const char *szMsgs2[] = { "hello", "back" };
const char **szMsg = szMsgs1; //our "const" pointer
szMsg = szMsgs2; //This is valid
szMsg[1] = szMsgs2[1]; //This is valid
szMsg[0][0] = 'H'; //This invalid valid


The reason it is complaining is that the thing you want to change from non-const to const is at the 2nd level. 2 pointers must be traversed before you reach the constant data.
QuestionDoModal [modified] Pin
john56326-Feb-11 20:16
john56326-Feb-11 20:16 
AnswerRe: DoModal Pin
Cedric Moonen6-Feb-11 21:30
Cedric Moonen6-Feb-11 21:30 
QuestionHow to provent text selection in CComboBox ? Pin
mesajflaviu6-Feb-11 20:01
mesajflaviu6-Feb-11 20:01 
AnswerRe: How to provent text selection in CComboBox ? Pin
mesajflaviu6-Feb-11 20:20
mesajflaviu6-Feb-11 20:20 
QuestionRe: How to provent text selection in CComboBox ? Pin
David Crow7-Feb-11 3:27
David Crow7-Feb-11 3:27 
AnswerRe: How to provent text selection in CComboBox ? Pin
mesajflaviu7-Feb-11 5:06
mesajflaviu7-Feb-11 5:06 
QuestionReading the file that create from "Print to file" option Pin
Max++6-Feb-11 16:09
Max++6-Feb-11 16:09 
AnswerRe: Reading the file that create from "Print to file" option Pin
Andrew Brock6-Feb-11 18:38
Andrew Brock6-Feb-11 18:38 
Questionhello, anyone have an idea of a code in MFC to shut down with time the pc ? in Vs 2008 ? Pin
leech4ever6-Feb-11 13:49
leech4ever6-Feb-11 13:49 
AnswerRe: hello, anyone have an idea of a code in MFC to shut down with time the pc ? in Vs 2008 ? Pin
«_Superman_»6-Feb-11 15:13
professional«_Superman_»6-Feb-11 15:13 
AnswerRe: hello, anyone have an idea of a code in MFC to shut down with time the pc ? in Vs 2008 ? Pin
Andrew Brock6-Feb-11 15:23
Andrew Brock6-Feb-11 15:23 
QuestionHow to make a book provision for multiple authors Pin
Horace Cheng6-Feb-11 11:49
Horace Cheng6-Feb-11 11:49 
AnswerRe: How to make a book provision for multiple authors Pin
Maximilien6-Feb-11 17:11
Maximilien6-Feb-11 17:11 
AnswerRe: How to make a book provision for multiple authors Pin
Richard MacCutchan6-Feb-11 22:08
mveRichard MacCutchan6-Feb-11 22:08 
QuestionBluetooth socket programming Pin
Pranit Kothari6-Feb-11 7:05
Pranit Kothari6-Feb-11 7:05 
AnswerRe: Bluetooth socket programming Pin
Cool_Dev6-Feb-11 18:12
Cool_Dev6-Feb-11 18:12 
GeneralRe: Bluetooth socket programming Pin
Pranit Kothari6-Feb-11 18:29
Pranit Kothari6-Feb-11 18:29 

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.