error C2248: cannot access protected member declared in class '****'
from: http://hi.baidu.com/%BC%BC%CA%F5%B2%BB%CA%C7%B7%B9%CD%EB/blog/item/496b5b507143c5858d54305f.html
vs2008下,從“類”建立的物件無法訪問該“類”的 protected 或 private 成員,不可以執行拷貝建構函式。
我遇到這個問題時,情況是這樣的:
=> 本來有一個類QGraphicsItem,我新增新類GeologicalItem並繼承自該類:
class GeologicalItem : public QGraphicsItem
{
public:
GeologicalItem();
protected:
private:
// 資料成員。
int i;
int j;
}
情況大概就是這樣。編譯就出現error C2248錯誤。
vs2008下,從“類”建立的物件無法訪問該“類”的 protected 或 private 成員,不可以執行拷貝建構函式
解決方法:自己編寫新類的複製建構函式和賦值建構函式:
GeologicalItem(const GeologicalItem &item);
GeologicalItem& operator=(const GeologicalItem &item);
編譯,成功通過!
相關文章
- O/S-Error: (OS 33) The process cannot access the fileError
- error:declared inside parameter listErrorIDE
- Cannot Access Pls Pages: 'mod_security: Access denied with code 400'
- php class中public,private,protected,static的區別,以及例項PHP
- Cannot access a disposed object.問題根源所在.....Object
- ORA-07274: spdcr: access error, access to oracle denied.ErrorOracle
- Uncaught Error: Cannot instantiate interfaceError
- ‘error: ‘‘this‘‘ cannot be implicitly captured in this context‘ErrorAPTContext
- Cannot access androidx.lifecycle.HasDefaultViewModelProviderFactoryAndroidViewIDE
- error: '[class name]' does not name a typeError
- Error: PLS-00201: identifier 'DBMS_AQ'must be declaredErrorIDE
- ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accuratelyErrorYAMLProject
- ERROR 1045 (28000): Access denied for userError
- xtrabackup: Error: cannot open /../../base/xtrabackup_checkpointsError
- Cannot decode object of class Employee for key (NS.object.0); the class may be defined in source cod...Object
- logstash nginx error access 日誌處理NginxError
- [筆記].痛哉!!!Error: Can't access JTAG chain, Error: Operation failed筆記ErrorAI
- Import Error: cannot import name ‘export_saved_modelImportErrorExport
- 關於React Native報Cannot access ‘serviceOf‘的解決方案React Native
- The entity "nbsp" was referenced, but not declared
- (Error -1170 @ 0x0) Unable to access the DAP)Error
- ERROR 1045 (28000): Access denied for user 'root'@'localhost'Errorlocalhost
- Error 1045(28000) Access Denied for user 'root'@'localhost'Errorlocalhost
- ScalaSigParserError: Unexpected error: Not a valid class fileError
- utilseq.h:92:30: error: ‘Iefp’ is not a class or namespaceErrornamespace
- C#中public、private、protected、internal、protected internal (轉載)C#
- The type XXX cannot be resolved.It is indirectly referenced from required .classUI
- Mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- Django WSGI Error:class.__dict__ not accessible in restricted modeDjangoErrorREST
- Error: Cannot find configuration directory: /etc/hadoopErrorHadoop
- configure: error: C++ compiler cannot create executablesErrorC++Compile
- PHP報錯:?configure: error: Cannot find libmysqlclientPHPErrorIBMMySqlclient
- FILE ON OCFS CANNOT BE DELETED LINUX ERROR: 16: DEVICE OR RESOURCE BUSYdeleteLinuxErrordev
- Error: cannot fetch last explain plan from PLAN_TABLEErrorASTAI
- Django Error: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissionsDjangoErrorORB
- MYSQL解決error: 'Access denied for user 'root'@'localhost' (using password:MySqlErrorlocalhost
- mysql ERROR 1045 (28000): Access denied for user解決方法MySqlError
- 解決錯誤:ASP.NET Error: Failed to access IIS metabaseASP.NETErrorAI