Beginner with C++ - Need helps with overload member function error
-
I'm trying to do programming C++ for my project. I got into trouble when I tried to do program for communicating with COM port(reading information in ComboBox). The error " overloaded member function 'class CString(class CComboBox &a) not found in 'CXeedlg'. Could someone help me to overcome ? overloaded member function not found in 'class' The following is my code: " CString getCurStrInComboBox(const CComboBox &a) { CString str; a.getLBText(a.GetCurSel(),str); return str; } " And the 2nd one is I dont know the reason why the complier informed that InsertString, AddString, GetCursel() arent members of ComboBox. The deadline for my project is coming soon so I will really appreciate all your helps. Thank you very much
-
I'm trying to do programming C++ for my project. I got into trouble when I tried to do program for communicating with COM port(reading information in ComboBox). The error " overloaded member function 'class CString(class CComboBox &a) not found in 'CXeedlg'. Could someone help me to overcome ? overloaded member function not found in 'class' The following is my code: " CString getCurStrInComboBox(const CComboBox &a) { CString str; a.getLBText(a.GetCurSel(),str); return str; } " And the 2nd one is I dont know the reason why the complier informed that InsertString, AddString, GetCursel() arent members of ComboBox. The deadline for my project is coming soon so I will really appreciate all your helps. Thank you very much
Don't you need a class name in front of that function? As in, CXeedlg::getCurStrInComboBox
-
I'm trying to do programming C++ for my project. I got into trouble when I tried to do program for communicating with COM port(reading information in ComboBox). The error " overloaded member function 'class CString(class CComboBox &a) not found in 'CXeedlg'. Could someone help me to overcome ? overloaded member function not found in 'class' The following is my code: " CString getCurStrInComboBox(const CComboBox &a) { CString str; a.getLBText(a.GetCurSel(),str); return str; } " And the 2nd one is I dont know the reason why the complier informed that InsertString, AddString, GetCursel() arent members of ComboBox. The deadline for my project is coming soon so I will really appreciate all your helps. Thank you very much
First: The member function listed in the compiler message looks like a conversion constructor for the class CString, taking a parameter of type CComboBox. Apparently the compiler found a function call somewhere in your code that requires a parameter of type CString, but you passed it a parameter of type CComboBox. Therefore it tried to find a conversion function from CComboBox to CString, and because it didn't find one, it issued this error message. Solution: locate the position in your code that the error message points to and replace the CComboBox argument with one of type String, or convertible to CString. (P.S.: the error message looks like there's something missing - it might just be what Chuck said) Second: This might be a followup error, but I cannot fathom how. You might have forgotten to include the right header, but I doubt that - it would cause quite a lot more errors, and the compiler wouldn't even recognize the symbol CComboBox to be a class. Maybe you mistyped the type CComboBox for ComboBox, like you did in your posting? It might be helpful to see a piece of code that these error messages point to.
-
Don't you need a class name in front of that function? As in, CXeedlg::getCurStrInComboBox
That was my bad in typing. I also have that part. I also wanna ask you guys more questions. "void CXbeefixedDlg::InitComboBox() { // ComboBox ComPort m_cboComport.ResetContent(); m_cboComport.AddString("COM1"); m_cboComport.AddString("COM2"); m_cboComport.AddString("COM3"); m_cboComport.AddString("COM4"); m_cboComport.SetCurSel(2); // ComboBox BitRate m_cboBitrate.ResetContent(); m_cboBitrate.InsertString(0,"1200"); m_cboBitrate.InsertString(1,"2400"); m_cboBitrate.InsertString(2,"4800"); m_cboBitrate.InsertString(3,"9600"); m_cboBitrate.InsertString(4,"19200"); m_cboBitrate.InsertString(5,"38400"); m_cboBitrate.InsertString(6,"57600"); m_cboBitrate.InsertString(7,"115200"); m_cboBitrate.InsertString(8,"230400"); m_cboBitrate.SetCursel(3); // Combobox Databit m_cboDatabits.ResetContent(); m_cboDatabits.AddString("4"); m_cboDatabits.AddString("5"); m_cboDatabits.AddString("6"); m_cboDatabits.AddString("7"); m_cboDatabits.AddString("8"); m_cboDatabits.SetCurSel(0); //Combox Stopbit m_cboStopbits.ResetContent(); m_cboStopbits.AddString("1"); m_cboStopbits.AddString("1.5"); m_cboStopbits.AddString("2"); m_cboStopbits.SetCurSel(0); //Combox Paritybit m_cboParitybit.ResetContent(); m_cboParitybit.InsertSring(0,"None"); m_cboParitybit.InsertString(1,"Odd"); m_cboParitybit.InsertString(2,"Even"); m_cboParitybit.InsertString(3,"Mark"); m_cboParitybit.InsertString(4,"Space"); m_cboParitybit.SetCursel(0); } void CXbeefixedDlg::Settings() { // Check whether port was openned, Close port to setup parameter if (m_mscomm.SetPortOpen()) m_mscomm.SetPortOpen(false); // Initialize Port name m_mscomm.SetCommPort(m_cboComport.GetCursel()+1); // Initialize parameters, databits, stopbits, parity bits, flowcontrol CString strBitrate = getCurStrInCombobox(m_cboBitrate); CString strParitybit = getCurStrInCombobox(m_cboParitybit); CString strStopbits = getCurStrInCombobox(m_cboStopbits); CString strDatabits = getCurStrInCombobox(m_cboDatabits); //Cstring strflowcontrol = getCurStrInCombobox(m_FlowControl); CString strSetting; strSetting.Format("%s,%c.%s,%s",strBitrate,strParitybit[1],strStopbits,strDatabits); m_mscomm.SetSettings(strSetting); // Other initializations m_mscomm.SetRThreshold(1); m_mscomm.SetInputlen(2); // Read 2 characters per once time m_mscomm.SetInputBufferSize(1024); m_mscomm.SetInputMode(0); // 0 - Text mode, 1 - Binary Mode m_mscomm.SetPortOpen(true); // Open COM port }
-
That was my bad in typing. I also have that part. I also wanna ask you guys more questions. "void CXbeefixedDlg::InitComboBox() { // ComboBox ComPort m_cboComport.ResetContent(); m_cboComport.AddString("COM1"); m_cboComport.AddString("COM2"); m_cboComport.AddString("COM3"); m_cboComport.AddString("COM4"); m_cboComport.SetCurSel(2); // ComboBox BitRate m_cboBitrate.ResetContent(); m_cboBitrate.InsertString(0,"1200"); m_cboBitrate.InsertString(1,"2400"); m_cboBitrate.InsertString(2,"4800"); m_cboBitrate.InsertString(3,"9600"); m_cboBitrate.InsertString(4,"19200"); m_cboBitrate.InsertString(5,"38400"); m_cboBitrate.InsertString(6,"57600"); m_cboBitrate.InsertString(7,"115200"); m_cboBitrate.InsertString(8,"230400"); m_cboBitrate.SetCursel(3); // Combobox Databit m_cboDatabits.ResetContent(); m_cboDatabits.AddString("4"); m_cboDatabits.AddString("5"); m_cboDatabits.AddString("6"); m_cboDatabits.AddString("7"); m_cboDatabits.AddString("8"); m_cboDatabits.SetCurSel(0); //Combox Stopbit m_cboStopbits.ResetContent(); m_cboStopbits.AddString("1"); m_cboStopbits.AddString("1.5"); m_cboStopbits.AddString("2"); m_cboStopbits.SetCurSel(0); //Combox Paritybit m_cboParitybit.ResetContent(); m_cboParitybit.InsertSring(0,"None"); m_cboParitybit.InsertString(1,"Odd"); m_cboParitybit.InsertString(2,"Even"); m_cboParitybit.InsertString(3,"Mark"); m_cboParitybit.InsertString(4,"Space"); m_cboParitybit.SetCursel(0); } void CXbeefixedDlg::Settings() { // Check whether port was openned, Close port to setup parameter if (m_mscomm.SetPortOpen()) m_mscomm.SetPortOpen(false); // Initialize Port name m_mscomm.SetCommPort(m_cboComport.GetCursel()+1); // Initialize parameters, databits, stopbits, parity bits, flowcontrol CString strBitrate = getCurStrInCombobox(m_cboBitrate); CString strParitybit = getCurStrInCombobox(m_cboParitybit); CString strStopbits = getCurStrInCombobox(m_cboStopbits); CString strDatabits = getCurStrInCombobox(m_cboDatabits); //Cstring strflowcontrol = getCurStrInCombobox(m_FlowControl); CString strSetting; strSetting.Format("%s,%c.%s,%s",strBitrate,strParitybit[1],strStopbits,strDatabits); m_mscomm.SetSettings(strSetting); // Other initializations m_mscomm.SetRThreshold(1); m_mscomm.SetInputlen(2); // Read 2 characters per once time m_mscomm.SetInputBufferSize(1024); m_mscomm.SetInputMode(0); // 0 - Text mode, 1 - Binary Mode m_mscomm.SetPortOpen(true); // Open COM port }
is this in your code or is this more "typo" during entry:
Quote:
CComBoBox
you have too many capital "B"s in your CComboBox :)
-
That was my bad in typing. I also have that part. I also wanna ask you guys more questions. "void CXbeefixedDlg::InitComboBox() { // ComboBox ComPort m_cboComport.ResetContent(); m_cboComport.AddString("COM1"); m_cboComport.AddString("COM2"); m_cboComport.AddString("COM3"); m_cboComport.AddString("COM4"); m_cboComport.SetCurSel(2); // ComboBox BitRate m_cboBitrate.ResetContent(); m_cboBitrate.InsertString(0,"1200"); m_cboBitrate.InsertString(1,"2400"); m_cboBitrate.InsertString(2,"4800"); m_cboBitrate.InsertString(3,"9600"); m_cboBitrate.InsertString(4,"19200"); m_cboBitrate.InsertString(5,"38400"); m_cboBitrate.InsertString(6,"57600"); m_cboBitrate.InsertString(7,"115200"); m_cboBitrate.InsertString(8,"230400"); m_cboBitrate.SetCursel(3); // Combobox Databit m_cboDatabits.ResetContent(); m_cboDatabits.AddString("4"); m_cboDatabits.AddString("5"); m_cboDatabits.AddString("6"); m_cboDatabits.AddString("7"); m_cboDatabits.AddString("8"); m_cboDatabits.SetCurSel(0); //Combox Stopbit m_cboStopbits.ResetContent(); m_cboStopbits.AddString("1"); m_cboStopbits.AddString("1.5"); m_cboStopbits.AddString("2"); m_cboStopbits.SetCurSel(0); //Combox Paritybit m_cboParitybit.ResetContent(); m_cboParitybit.InsertSring(0,"None"); m_cboParitybit.InsertString(1,"Odd"); m_cboParitybit.InsertString(2,"Even"); m_cboParitybit.InsertString(3,"Mark"); m_cboParitybit.InsertString(4,"Space"); m_cboParitybit.SetCursel(0); } void CXbeefixedDlg::Settings() { // Check whether port was openned, Close port to setup parameter if (m_mscomm.SetPortOpen()) m_mscomm.SetPortOpen(false); // Initialize Port name m_mscomm.SetCommPort(m_cboComport.GetCursel()+1); // Initialize parameters, databits, stopbits, parity bits, flowcontrol CString strBitrate = getCurStrInCombobox(m_cboBitrate); CString strParitybit = getCurStrInCombobox(m_cboParitybit); CString strStopbits = getCurStrInCombobox(m_cboStopbits); CString strDatabits = getCurStrInCombobox(m_cboDatabits); //Cstring strflowcontrol = getCurStrInCombobox(m_FlowControl); CString strSetting; strSetting.Format("%s,%c.%s,%s",strBitrate,strParitybit[1],strStopbits,strDatabits); m_mscomm.SetSettings(strSetting); // Other initializations m_mscomm.SetRThreshold(1); m_mscomm.SetInputlen(2); // Read 2 characters per once time m_mscomm.SetInputBufferSize(1024); m_mscomm.SetInputMode(0); // 0 - Text mode, 1 - Binary Mode m_mscomm.SetPortOpen(true); // Open COM port }
Most likely, this is your problem:
CString CXbeefixedDlg::getCurStrInCombobox(const CComBoBox &a)
Instead of CComBoBox, it should be CComboBox Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193