Click here to Skip to main content
15,906,335 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralActive X Pin
racing577-Feb-05 3:36
racing577-Feb-05 3:36 
GeneralNM_CUSTOMBAR returns void, how to use it correctly Pin
bilas7-Feb-05 2:30
bilas7-Feb-05 2:30 
GeneralRe: NM_CUSTOMBAR returns void, how to use it correctly Pin
Michael Dunn7-Feb-05 6:58
sitebuilderMichael Dunn7-Feb-05 6:58 
GeneralShared Folder Access Pin
ashtwin7-Feb-05 2:14
ashtwin7-Feb-05 2:14 
GeneralRe: Shared Folder Access Pin
Antony M Kancidrowski7-Feb-05 2:33
Antony M Kancidrowski7-Feb-05 2:33 
GeneralRe: Shared Folder Access Pin
Rick Crone9-Feb-05 10:58
Rick Crone9-Feb-05 10:58 
GeneralMicrosoft Real Time communications Client API SDK Pin
jerry0davis7-Feb-05 1:46
jerry0davis7-Feb-05 1:46 
GeneralLearn C++ in 21 Days? I wish! Pin
RicD337-Feb-05 1:15
RicD337-Feb-05 1:15 
Just in case anyone else has this guide or access to it to see what I mean, it is calle "Teach Yourself C++ In 21 Days" and is published by MacMillan. I am stuck on "Day 2" in the book, page #34 (54/792 if you include the prefix pages)...

Just telling ppl this so they dont have to take my word for it, the book is wrong and I would advise anyone learning from this book, you will get errors sooner or later!

I have made an empty shell of a program with Visual C++ going off Day 2 in this book.

This program has various fixed buttons and variable (tick/untick) boxes.

There are 6 variables on the program window altogether:

1: A field to type in a message (edit box)
2: A drop down "combo box"
3: (and 4, 5 & 6) are all tick/untick boxes inside group boxes, to switch some things on or off

The book I am learning from states to include the following code to make the edit box display a message and for the 4 checkboxes to be ticked when the program is run. The other 6th variable, the combo box, is left alone in this part of the code, it just displays "Notepad, Paint" and a button is next to that called "Run Program"

So these 5 variables are set out in this code like so:

1: BOOL CDay2REDODlg::OnInitDialog()
2: {
3: CDialog::OnInitDialog();
4:
5: .
6: .
7: .
8:
9: // TODO: Add extra initialization here
10:
11: ///////////////////////
12: // MY CODE STARTS HERE
13: ///////////////////////
14:
15: // Put a default message in the message edit
16: m_strMessage = "Place a message here";
17:
18: // Set all of the check boxes to checked
19: m_bShowMsg = TRUE;
20: m_bShowPgm = TRUE;
21: m_bEnableMessage = TRUE;
22: m_bEnablePgm = TRUE;
23:
24: // Update the dialog with the values
25: UpdateData(FALSE);
26:
27: ///////////////////////
28: // MY CODE ENDS HERE
29: ///////////////////////
30:
31: return TRUE; // return TRUE unless you set the focus to a control
32: }

This is the code from the book, copied exactly, although I am using a .PDF file, and this is a nightmare, thanks Adobe, thanks for not letting us highlight or edit the text in PDF files so we have to hand typa ALL code we might find in these books, and thanks for somehow making PDF files 20 times larger than .TXT files are whilst taking all the edit functions away, seems like degression from notepad text files to me not better.

Anyway, with my Adobe anger aside, I put in the code without the 32 numbers by the side - and got 27 errors.

So I then put in the 32 numbers, and got only 3 errors. Knowing my luck, these numbers are completely blocking out the code or something hence less errors? Here is the full error log:

Deleting intermediate files and output files for project 'Day2REDO - Win32 Debug'.
--------------------Configuration: Day2REDO - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
Day2REDO.cpp
Day2REDODlg.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Day2REDO\Day2REDODlg.cpp(103) : error C2143: syntax error : missing ';' before 'constant'
C:\Program Files\Microsoft Visual Studio\MyProjects\Day2REDO\Day2REDODlg.cpp(104) : error C2143: syntax error : missing ';' before 'constant'
C:\Program Files\Microsoft Visual Studio\MyProjects\Day2REDO\Day2REDODlg.cpp(104) : fatal error C1004: unexpected end of file found
Generating Code...
Error executing cl.exe.

Day2REDO.exe - 3 error(s), 0 warning(s)

As you can see I have called Day 2 "REDO" because I am again at the same point I was before with these 3 errors.

I know its adding these 5 variable functions to the boxes and list box that is making these 3 errors, because I can build the program just before doing this and it is fine.

I have fun doing this, then something completely out of my hands this happens! There are hundreds of others with this same problem, from beginners to advanced. Some posts I have read, the developer is in real trouble, not able to compile their code before their deadline etc, at least its not that bad for me, these are advanced developers too! So how am I going to sort it out?

I must have read at least ten answers people gave to solve the problem and none work.

I fear the problem is with Microsoft Visual C++ not the book I am learning from. Perhaps this is why Borland is the preffered choice? I am only using Microsoft Visual C++ because my guide is written for that program and doesnt mention borland.

It does not state anywhere about these errors you will encounter after using their book. This is what makes it hard for people to learn C++. It actually isnt that hard, thats probably how I started enjoying it, understanding it, but you follow these books by the letter and then you get errors!

Therefore, I am NOT learning C++ am I?!

Sorry to be so sarcastic, it probably is something I am missing in the book (maybe) but does anyone know why this error happens? No ; before 'constant'. Yeah but, there is no single instance of the word "constant" in my script! It seems like C++ itself needs some development here.

I have seen "No ')' before 'constant'" too, same error really, no one knowws why. I put a semi colon after all my commands. Lets face it, I only put in 32 lines of code and probably less than 5 commands, all with semi-colons, all copied exactly from the book.

Nowhere in the program can you find why the error happens, so here I post this, lol
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Antony M Kancidrowski7-Feb-05 1:25
Antony M Kancidrowski7-Feb-05 1:25 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Maximilien7-Feb-05 1:34
Maximilien7-Feb-05 1:34 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
RicD337-Feb-05 1:53
RicD337-Feb-05 1:53 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Maximilien7-Feb-05 2:28
Maximilien7-Feb-05 2:28 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
RicD337-Feb-05 2:34
RicD337-Feb-05 2:34 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Maximilien7-Feb-05 2:43
Maximilien7-Feb-05 2:43 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Bob Ciora7-Feb-05 6:16
Bob Ciora7-Feb-05 6:16 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
V.7-Feb-05 2:54
professionalV.7-Feb-05 2:54 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
RicD337-Feb-05 13:32
RicD337-Feb-05 13:32 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Cedric Moonen7-Feb-05 3:35
Cedric Moonen7-Feb-05 3:35 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Wes Aday7-Feb-05 4:45
professionalWes Aday7-Feb-05 4:45 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
RicD337-Feb-05 13:57
RicD337-Feb-05 13:57 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Wes Aday7-Feb-05 17:45
professionalWes Aday7-Feb-05 17:45 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
RicD338-Feb-05 2:40
RicD338-Feb-05 2:40 
GeneralRe: Learn C++ in 21 Days? I wish! Pin
Anonymous9-Mar-05 13:09
Anonymous9-Mar-05 13:09 
GeneralPostMessage() Pin
includeh107-Feb-05 0:17
includeh107-Feb-05 0:17 
GeneralRe: PostMessage() Pin
Cedric Moonen7-Feb-05 1:14
Cedric Moonen7-Feb-05 1:14 

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.