| | |
help with "disabling" a button
![]() |
•
•
Join Date: Feb 2005
Posts: 46
Reputation:
Solved Threads: 0
I'm doing a "magic square" program and I'm having trouble with a button. It is supposed to stay active for as many clicks as it takes to fill the array storing the numbers, then become disabled. The button stops working the first time i click it though, and i dont know what i'm doing wrong. could someone help me please?
heres the code for my button.
and when I initialize "i" to zero, i get the error message:
error C2252: 'i' : pure specifier can only be specified for functions
heres the code for my button.
C Syntax (Toggle Plain Text)
void CLab10Dlg::OnEnterDataButton() { // TODO: Add your control notification handler code here GetDlgItemText(IDC_ROW_NUM, m_row_num); GetDlgItemText(IDC_COL_NUM, m_col_num); GetDlgItemText(IDC_DATA, m_data); int row_num = atoi((LPCTSTR)m_row_num); int col_num = atoi((LPCTSTR)m_col_num); int data = atoi((LPCTSTR)m_data); int i; if(i < num_rows_cols) { magic_array[row_num-1][col_num-1] = data; i++; } if(i >= num_rows_cols) m_enter_data_button.EnableWindow(false); }
error C2252: 'i' : pure specifier can only be specified for functions
•
•
Join Date: Mar 2005
Posts: 22
Reputation:
Solved Threads: 0
I may be wrong on this, but I'll take a crack it. It looks as if you're declaring an int i, assigning it no value which in turn will leave some unknown garbage data. And since your array is probably not too large num_row_cols will probably be lower than the garbage data which can be as high as 65,536.
Edit: My apologies I didn't see the statement under your code.
int i; if(i < num_rows_cols) { magic_array[row_num-1][col_num-1] = data; i++; } if(i >= num_rows_cols) m_enter_data_button.EnableWindow(false);
Edit: My apologies I didn't see the statement under your code.
•
•
Join Date: Mar 2005
Posts: 22
Reputation:
Solved Threads: 0
I looked up this error and here is what I found.
Error:
pure specifier can only be specified for functions
Suggestion
In a class definition, you are not allowed to set variables or call functions (including other class constructors). Thus code such as int a = 0; and vector<int> b(10); is not allowed. Setting variables and calling functions should be done in constructors. To make a function a pure virtual function, one that must be overridden by a derived class, set the function =0, as in void Draw() = 0;
Error:
pure specifier can only be specified for functions
Suggestion
In a class definition, you are not allowed to set variables or call functions (including other class constructors). Thus code such as int a = 0; and vector<int> b(10); is not allowed. Setting variables and calling functions should be done in constructors. To make a function a pure virtual function, one that must be overridden by a derived class, set the function =0, as in void Draw() = 0;
•
•
Join Date: Feb 2005
Posts: 46
Reputation:
Solved Threads: 0
I still can't get it right. Could someone give me an example of something like what im trying to do? Or atleast tell me exactly what i have wrong. This is the only way i can think of to get the button to disable, and obviously its wrong.
My professor told me to define all of my variables in the header file directly before the "protected" area. And when i put the variable "i" there, that's when i get the error that i posted above.
Thx in advance for any help that you may offer me.
My professor told me to define all of my variables in the header file directly before the "protected" area. And when i put the variable "i" there, that's when i get the error that i posted above.
Thx in advance for any help that you may offer me.
![]() |
Similar Threads
- "Force Logoff" button on "Locked Workstation" window (Windows NT / 2000 / XP)
- Changing the default "submit" button. (HTML and CSS)
Other Threads in the C Forum
- Previous Thread: a problem wilth C program
- Next Thread: Nested template class
| Thread Tools | Search this Thread |
#include * adobe ansi api array asterisks binarysearch centimeter changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax database directory dynamic execv feet fgets file fork function getlasterror getlogicaldrivestrin givemetehcodez global grade gtkgcurlcompiling gtkwinlinux hacking hardware highest histogram ide include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opendocumentformat opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing segmentationfault sequential single socket socketprograming standard string systemcall threads turboc unix user voidmain() wab whythiscodecausesegmentationfault windows.h windowsapi





