报错,不能实例化自定义类Menu

图片说明
图片说明

2个回答

Menu的包导错了吧,Java本身自带的有一个java.awt.Menu类,看看是不是导成这个类了

@Autowired 注入

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
报错,不能实例化自定义类
[img=https://img-bbs.csdn.net/upload/201710/29/1509249431_788731.png][/img]rn[code=java]public class MainActivity extends Activity rn private ListView listView;rn private Cursor cursor;rn DBHelper dbHelper;rn SQLiteDatabase db;rn List menuList;rn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_main);rn dbHelper = new DBHelper(this,"digitialMenu.db",null,1);rn menuList = new ArrayList ();rn menuList = getListItems();rn listView = (ListView) findViewById(R.id.ListViewMenu);rn MenuAdapter adapter = new MenuAdapter(this, menuList);rn listView.setAdapter(adapter);rn rn rn public List getListItems() rn db= dbHelper.getWritableDatabase();rn cursor = db.rawQuery("select * from menu", null);rn List menuLists = new ArrayList ();rn while(cursor.moveToNext())rn int menuid= cursor.getColumnIndex("menuID");rn String menuName = cursor.getString(cursor.getColumnIndex("menuName"));rn String picture = cursor.getString(cursor.getColumnIndex("picture"));rn String description = cursor.getString(cursor.getColumnIndex("description"));rn int price = cursor.getColumnIndex("price");rn Menu menu = new Menu(menuid,menuName,picture,description,price);rn menuLists.add(menu);rn rn return menuLists;rn rn rn class MenuAdapter extends BaseAdapter rn private Context context;rn private ArrayList menuList;rn private LayoutInflater listContainer;rn rn public MenuAdapter(Context context, List menuList) rn this.context = context;rn listContainer=LayoutInflater.from(context);rn this.menuList = (ArrayList ) menuList;rn rn rn @Overridern public int getCount() rn return cursor.getCount();rn rn rn @Overridern public Object getItem(int position) rn return position;rn rn rn @Overridern public long getItemId(int position) rn return position;rn rn rn @Overridern public View getView(final int position, View convertView, ViewGroup parent) rn final int clickID = position;rn View items=listContainer.inflate(R.layout.activity_items,null);rn rn final ImageButton picture = (ImageButton)items.findViewById(R.id.ImageButtonItem);rn TextView menuName = (TextView)items.findViewById(R.id.TextViewItemName);rn TextView price = (TextView)items.findViewById(R.id.TextViewItemPrice);rn Button add = (Button)items.findViewById(R.id.ButtonItemAddOrder);rn rn menuName.setText(menuList.get(position).getMenuName());rn price.setText(String.valueOf(menuList.get(position).getPrice()));rn picture.setImageDrawable(Drawable.createFromPath(menuList.get(clickID).getPicture()));rn rn picture.setOnClickListener(new View.OnClickListener() rn @Overridern public void onClick(View v) rn ImageView img = new ImageView(context);rn //img.setImageResource(Integer.parseInt();rn AlertDialog dialog = new AlertDialog.Builder(context).create();rn dialog.setTitle("美食详情:");rn dialog.setView(img);rn dialog.setMessage(menuList.get(clickID).getDescription());rn dialog.setButton("确定", new DialogInterface.OnClickListener() rn @Overridern public void onClick(DialogInterface dialog, int which) rn rn );rn dialog.show();rn rn );rn add.setOnClickListener(new View.OnClickListener() rn @Overridern public void onClick(View v) rn rn rn );rn return items;rn rn rn rn [/code]rnrn[code=java]public class Menu rn int menuid;rn String menuName;rn String picture;rn String description;rn int price;rn public Menu(int menuid,String menuName,String picture,String description,int price)rn rn this.menuid=menuid;rn this.menuName=menuName;rn this.picture=picture;rn this.description=description;rn this.price=price;rn rn rn public String getMenuName()rn rn return menuName;rn rn public int getPrice()rn rn return price;rn rn public String getPicture()rn rn return picture;rn rn public String getDescription()rn rn return description;rn rn rnrn [/code]rnrn[code=java]public class DBHelper extends SQLiteOpenHelperrn private static final String name="digitialMenu.db";rn private static final int version =1;rn rn public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) rn super(context, name, null, version);rn rn rn rn @Overridern public void onCreate(SQLiteDatabase db) rn db.execSQL("create table worker(workerid varchar(10) primary key, username varchar(10),password varchar(20),type integer);");rn db.execSQL("insert into worker(workerID,username,password,type)values('wk01','admin','admin','1');");rn db.execSQL("insert into worker(workerID,username,password,type)values('wk02','waiter','waiter','2');");rn db.execSQL("insert into worker(workerID,username,password,type)values('wk03','chief','chief','3');");rn rn db.execSQL("CREATE TABLE menu(menuID integer primary key autoincrement,menuName varchar(20),picture varchar(20),description varchar(50),price integer);");rn db.execSQL("insert into menu(menuName,picture,description,price)values('干煸四季豆','gbsjd.jpg','时蔬四季豆','13');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('酸菜鱼','scy.jpg','热门酸菜鱼','30');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('毛血旺','mxw.jpg','招牌毛血旺','32');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('双味鱼头','swyt.jpg','特色双味鱼头','38');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('干锅包菜','ggbc.jpg','干锅包菜','15');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('有机花菜','yjhc.jpg','干锅有机花菜','16');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('苦瓜羹','kgg.jpg','汤品苦瓜羹','16');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('麻辣牛肉','mlnr.jpg','热菜麻辣牛肉','28');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('麻婆豆腐','mpdf.jpg','热菜麻婆豆腐','2');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('泡椒田鸡','pjtj','泡椒田鸡','43');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('飘香鱼','pxy.jpg','热菜飘香鱼','53');");rn db.execSQL("insert into menu(menuName,picture,description,price)values('水煮活鱼','szhy.jpg','热门水煮活鱼','30');");rn rn db.execSQL("CREATE TABLE ordertable(orderID integer primary key autoincrement, tablenum integer, ordertime varchar(20), state integer, notes varchar(20));");rn db.execSQL("CREATE TABLE orderdetail(orderdetialid integer primary key autoincrement, orderid integer, menuid integer, tablenum integer, quantity integer, detailsate integer);");rn rn rn @Overridern public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) rn db.execSQL("DROP TABLE IF EXISTS worker");rn db.execSQL("DROP TABLE IF EXISTS menu");rn db.execSQL("DROP TABLE IF EXISTS ordertable");rn db.execSQL("DROP TABLE IF EXISTS orderdetail");rn onCreate(db);rn rnrn rn [/code]
关于用户自定义类的实例化
如 怎么只能在UserControl中可以在navigation:Page 里怎么就不行了
MFC 自定义类 实例化在哪
CSellTicket s 有个CTicket类的成员变量a 若还有一个类想访问 CSellTicket 类中的CTicket成员变量a 怎么做到啊??? rnrn我知道 可以通过 set get 接口 rn但是 我通过MFC定义的类 .cpp .h中都找不到[color=#FF0000]自己定义的类的实例化[/color]在哪里????rn也就是找不到那个 srnrnrn更找不到 RUNTIME_CLASS(CSellTicket)rn两个问题rn[b]1.第三个类怎么访问上面的arn2.MFC 自定义类的实例化在哪里[/b]rn我该怎么办啊 !!!!rnrn还有就是CView的父窗口与父类(基类)不是一个概念吗
自定义类和类的实例化
// // Fraction.h #import /* @interface 部分用于描述类和类的方法 */ @interface Fraction : NSObject - (void)print; - (void)setNumerator:(int)n; - (void)setDenominator:(int)d; @end // // Fraction.m #import
求救!!自定义类实例化后作为参数传递到 webService中 报错
错误:不应是类型 ×××,使用 XmlInclude 或 SoapInclude 属性静态指定非已知的类型。 rn在asmx文件中添加[XmlInclude(typeof(×××))]也不好使啊,自定义类添加[] rn大哥帮忙解释下啊rn
jsp导入自定义类报错
自定义类:(能编译能运行) package example5; public class BicData{ private String weight = null; private String size = null; public BicData(String weight,String size){ this.weight=weight; this.size=...
PyCharm引入自定义类报错
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supp
自定义类的属性值不能保持
新建了一个类Arn添加了属性:rnstring _UserTab = "";rnpublic string UserTabrn rn get return _UserTab; rn set _UserTab = value; rn rn方法:rnpublic void GetUserTab()rnrn UserTab="123";rnrnrn在页面Page_Load事件中调用GetUserTab()后,访问UserTab属性,能获取到值:123rn但是在按钮事件中获取其UserTab属性,得到值却为空,怎么回事啊
自定义类的实例化对象转JSON--结合Runtime
具体分为两步 第一步将自定义类的实例化对象转为字典,这一步需要结合Runtime进行 第二步使用第一部得到的字典转为JSON数据
C#自定义类的数组实例化好象有点麻烦
[code=C#]rnclass Arnrn //一些属性rn public A()rn rn //提供给非B类使用的rn rn public A(int x,int y,int z,int _)//参数比较复杂(不只这几个)rn rn //提供给B类用的rn rnrnclass Brnrn //我想在B中定义化A类的十个实例(而且是静态的)rnrn ///一些属性rn rn //private static A[] myA=new A[10](); //这样会惊动A的第一个构造函数,rn //myA[0]=new A(x,y,z,_); //这样又会覆盖原来的实例,肯定会制造垃圾 rn //myA[1]=new A(x,y,z,_);rn // .rn // .rn // .rn //myA[10]=new A(x,y,z,_);rnrn //private static A[] myA=new A[10](参数很复杂直接这样实例化估计要写几英里),(),();rnrn //private static A[] myA;rn //myA[0]=new A(x,y,z,_); //这样好象会报错rn //myA[1]=new A(x,y,z,_); rn //myA[10]=new A(x,y,z,_); rn rnrnclass Crnrn //直接调用B.myA[0-----10];rnrn[/code]rn我想在B中定义化A类的十个实例(而且是静态的),谁的基础好能给我提供个更好的解决方法吗?
自定义类中限制使用原生实例化方法
在自定义的类中,除了有系统自带的实例化方法外,还可能会有开发者自定义的实例化方法。当不想使用系统自定义方法时,而仅使用自定义的实例化方法时,可以这样做下限制。如下示例所示: #import @interface MYView : UIView // 限制使用系统方法进行实例化 // 方法1 - (instancetype)init UNAVAILABLE_ATTRIBUTE; // 方法2
在Eclipse实例化对象报错
本人新人一枚,我按照视频教程练习java的重写 在实例化对象中出了问题 但是视频的没有报错,我的却会报错,这是什么原因呢?麻烦各位前辈指导
redis实例化报错
实例化 redis <?php new redis(); ?> 报以下错误 是运行PHP代码的这台机子 没有安装 redis 扩展 或 Fatal error: Uncaught Error: Class ‘redis’ not found in /home/wwwroot/default/REDIS/redis.php:3 Stack trace: #0 {main} thro...
实例化报错的原因总结
一:实例化报错的原因总结 A a=new B(); B()既可以是一个子类也;可以是一个构造方法 出错的原因:1.如果B没有继承A 2.被继承的类为final类 3.如果B是一个接口 4.A B类名字 写错了 5.B()构造器里面的参数未传入 6.A B类的包没有引入 7.构造方法被Private 8.B类是抽象类 9.变量名冲突如a在之前被赋值了int a=10 A...
串口实例化报错'System.InvalidOperationException'
[img=https://img-bbs.csdn.net/upload/201805/03/1525352859_296742.png][/img][img=https://img-bbs.csdn.net/upload/201805/03/1525352868_875434.png][/img][img=https://img-bbs.csdn.net/upload/201805/03/1525352874_916074.png][/img]
两个类,实例化问题,实例化报错
public class Paixu n n public static void main(String[] args) n n // Paixu px=new Paixu();n n MaoPaoSort mp=new MaoPaoSort();n n //上面这里就开始报错了:No enclosing instance of type Paixu is accessible. Must qualify the allocation with an enclosing instance of type Paixu (e.g. x.new A() where x is an instance of Paixu).n n n class MaoPaoSort n public void test1() n int a[] = 1, 1234, 356, 123, 56346, 73, 45342342, 1, 3, 56, ;nn for (int i = 0; i < a.length; i++) nn for (int j = i + 1; j < i - 1; j++) n if (a[i] < a[j]) n int tmp = a[i];n a[i] = a[j];n a[j] = tmp;n System.out.println(a[j]);n n n n n nn n nn
menu的navigateurl不能带参数?
asp:MenuItem NavigateUrl="~/ST_test.aspx?u_id='"+"<%=u_id%>'"不知道怎么写。用上+号就出错。。不知道怎么写。
“CException”: 不能实例化抽象类
e:\vc\bitmap\bitmap\cdib.cpp(471) : error C2259: “CException”: 不能实例化抽象类rn 由于下列成员:rn “CException::~CException(void)”: 是抽象的rn c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(743) : 参见“CException::~CException”的声明rnrn该要怎么改正啊?谢谢啦
不能实例化抽象类
有两个类,一个PrinterMonitor抽象类,一个MyPrinterMonitor具体类。在实例化的时候,告诉我不能实例化抽象类。现在正在学设计模式,如果C++不能实例化抽象类那要怎么实现所期望的功能呢?rn我找了一些资料,里面的代码也是这么写的,但我的编译为什么出错?rn代码如下:rnrn//PrinterMonitor.h文件rn#include "Printer.h"rn#include"ChargeFormStrategy.h"rn#include"Filter.h"rn#include"Printer.h"rn/**rn * 打印机监视器抽象类rn */rnclass PrinterMonitorrnrnrnpublic:rn ~PrinterMonitor();rn virtual void startMonitor() =0;rn rn virtual void monitor() =0;rn virtual Printer getPrinter() =0;rnprotected:rn PrinterMonitor();rnprivate:rnrn Printer printer;rn ChargeFormStrategy chargeFormStrategy;rnrn Filter filter;rnrn;rn#endifrnrnrn//MyPrinterMonitor.h文件rnrn///////////////////////////////////////////////////////////rn// MyPrinterMonitor.hrn// Implementation of the Class MyPrinterMonitorrn// Created on: 20-二月-2014 15:36:11rn// Original author: Administratorrn///////////////////////////////////////////////////////////rnrn#if !defined(EA_B1612F76_2F98_4fa4_A5C6_B3B703B4379C__INCLUDED_)rn#define EA_B1612F76_2F98_4fa4_A5C6_B3B703B4379C__INCLUDED_rnrn#include "PrinterMonitor.h"rnrnclass MyPrinterMonitor : public PrinterMonitorrnrnrnpublic:rn virtual ~MyPrinterMonitor();rnrn MyPrinterMonitor();rn void startMonitor();rnprivate:rnrn void monitor();;rn#endif rnrn//测试rnint main()rn PrinterMonitor* myPtMonitor;rnrnrn //此报错:error C2259: “MyPrinterMonitor”: 不能实例化抽象类rn myPtMonitor= new MyPrinterMonitor();rn rnrnreturn 0;rnrn
"CAlarmMessage":不能实例化抽象类
[code=C/C++]////////////////////1 AlarmMessage.hrnclass CAlarmMessage : public CAlarmReceiverrnrnpublic:rn CAlarmMessage();rn ~CAlarmMessage(void);rnrnpublic:rn virtual void NetDisConnect( LONG lLoginID, DWORD dwUser); //网络断线rn virtual int RecogATMDataCallback(); //回调函数rnrnrn/////////////////2 AlarmMessage.cpprnCAlarmMessage::CAlarmMessage()rnrnrnrnCAlarmMessage::~CAlarmMessage(void)rnrnrnrn//回调函数rnint CAlarmMessage::RecogATMDataCallback()rnrn //具体实现rn return 0 ;rnrnrn/////////////////3 My.cpprn#include "My.h"rn#include "AlarmMessage.h"rnrnchar *m_img ;rnint m_imgLen ;rnCAlarmMessage *m_pAlarmmsg = NULL;rnrn//函数rnlong Init()rn rn USES_CONVERSION;rn m_pAlarmmsg = new CAlarmMessage() ; //错误“CAlarmMessage”: 不能实例化抽象类rn //为什么这里会出现这种报错呢?rn m_img = (char*)malloc( 500 * 1024 ) ; //分配空间以存放图片rn m_imgLen = 0 ;rnrn return 1;rn[/code]
TXMLDocument为什么不能实例化?
我想生成一个XML,在内存中保存一些数据rn用这样的代码rnvarrn Data : TXMLDocument;rnbeginrn Data := TXMLDocument.Create(Self);rn ......rnrn编译报错。rn查帮助,发现TXMLDocument的Create用了reintroduce这个关键字后需要一个AFileName参数,但用这个运行时又报“标记没有存储”的错误。rn况且从组件面板拖下来的TXMLDocument不用指定文件名也能实例化啊,不用非设置文件名吧,我只是想在内存中生成一个XML格式的数据而已。rn高手指教。谢谢。
为什么不能实例化
学了C#很久了可还不知道在c#中为什么String 不能实例化StringBuilder能实例化呢?
接口不能实例化?
[color=#FF0000]IEngineFeatureSnapAgent featureSnapAgent = new EngineFeatureSnap();[/color]rnrn虽然明明知道,接口是不能实例化的,但是我今天又看到了[color=#FF00FF]将接口new的语句[/color],而且代码可以正常运行,没有任何错误。第一次见到将接口new是在将datagridview里的数据导入excel里时:rnrn [color=#FF0000] Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();[/color]rn而且也能正常运行。rnrn真是搞不懂,明明接口不能实例化,那为什么却能像实例化类一样实例化接口呢???而且完全正常使用。这到底是“实例化”吗??
抽象基类不能实例化的问题
今天看了一段代码。抽象基类竟然被实例化了,并且在vs中编译没有错误。。rn在前看c++ primer是抽象基类是不能被实例化的,,请问各位大神,为什么这段代码能正常运行。rnrn[code=c]rn//subject.h文件rn#ifndef OBSERVER_Hrn#define OBSERVER_Hrn#include "subject.h"rn#include rnclass Observerrnpublic:rn virtual ~Observer();//析构函数最好加关键字virtualrn virtual void Update(Subject* sub) = 0;rn virtual void PrintInfo() =0;rnprotected:rn Observer();rn //std::string _st;rnprivate:rn;rnrnclass StockObserver:public Observerrnpublic:rn virtual Subject* GetSubject();rn StockObserver(Subject* sub,std::string name);rn virtual ~StockObserver();rn //传入Subject作为参数,这样可以让一个View属于多个的Subject。rn void Update(Subject* sub);rn void PrintInfo();rnprotected:rnprivate:rn Subject* _sub;rn std::string _name;rn;rnrnclass NBAObserver:public Observerrnrnpublic:rn virtual Subject* GetSubject();rn NBAObserver(Subject* sub,string name);rn virtual ~NBAObserver();rn //传入Subject作为参数,这样可以让一个View属于多个的Subject。rn void Update(Subject* sub);rn void PrintInfo();rnprotected:rnprivate:rn Subject* _sub;rn std::string _name;rn;rn#endif[/code]rn[code=c][/code]rn[code=c]//observer.cpprn#include "observer.h"rn#include "subject.h"rn#include rn#include rnusing namespace std;rnObserver::Observer()rnrn //_st = '\0';rnrnObserver::~Observer()rnrnrnStockObserver::StockObserver(Subject* sub,std::string name)rnrn _sub = sub;rn //_sub->Attach(this);rn _name=name;rnrnStockObserver::~StockObserver()rnrn //_sub->Detach(this);rn if (_sub != 0)rn delete _sub;rnrnSubject* StockObserver::GetSubject()rnrn return _sub;rnrnvoid StockObserver::PrintInfo()rnrn cout<<_sub->GetState()<<","<<_name<<"关掉股票,开始练功"<GetState();rn PrintInfo();rnrnNBAObserver::NBAObserver(Subject* sub,std::string name)rnrn _sub = sub;rn //_sub->Attach(this);rn _name=name;rnrnNBAObserver::~NBAObserver()rnrn //_sub->Detach(this);rn if (_sub != 0)rn rn delete _sub;rn rnrnSubject* NBAObserver::GetSubject()rnrn return _sub;rnrnvoid NBAObserver::PrintInfo()rnrn cout<<_sub->GetState()<<","<<_name<<"关掉NBA,继续练功"<GetState();rn PrintInfo();rn[/code]rnrn[code=c]rn#ifndef SUBJECT_Hrn#define SUBJECT_Hrn#include rn#include rnusing namespace std;rnclass Observer; //不要忘记rnclass Subjectrnrnpublic:rn virtual ~Subject();rn virtual void Attach(Observer* obv);rn virtual void Detach(Observer* obv);rn virtual void Notify();rn virtual void SetState(const string& st) = 0;rn virtual string GetState() = 0;rnprotected:rn Subject();rnprivate:rn list _obvs;rn;rnclass BossSubject:public Subjectrnrnpublic:rn BossSubject();rn ~BossSubject();rn string GetState();rn void SetState(const string& st);rnprotected:rnprivate:rn string _st;rn;rn#endifrn[/code]rnrnrn[code=c]rn#include "subject.h"rn#include "observer.h"rn#include rn#include rnusing namespace std;rnSubject::Subject()rn //在模板的使用之前一定要new,创建rn //_obvs = new list;rnrnSubject::~Subject()rn rnvoid Subject::Attach(Observer* obv)rnrn _obvs.push_front(obv);rnrnvoid Subject::Detach(Observer* obv)rnrn if (obv != NULL)// 迭代器 实际上就是一个指针rn _obvs.remove(obv);rnrnvoid Subject::Notify()rnrn list::iterator it;rn it = _obvs.begin();rn for (;it != _obvs.end();it++)rn //关于模板和iterator的用法rn (*it)->Update(this);rn rnrnBossSubject::BossSubject()rnrn _st = '\0';rnrnBossSubject::~BossSubject()rn rnstring BossSubject::GetState()rnrn return _st;rnrnvoid BossSubject::SetState(const string& st)rn rn _st = st;rn[/code]rnrn[code=c]//main.cpprn#include "subject.h"rn#include "observer.h"rn#include rn#include rnusing namespace std;rnint main(int argc,char* argv[])rnrn BossSubject* sub = new BossSubject();rn Observer* o1 = new StockObserver(sub,"郭靖");//实例化基类rn Observer* o2 = new NBAObserver(sub,"黄蓉");rn sub->SetState("我胡汉三又回来了");rn sub->Attach(o1);rn sub->Attach(o2);rn sub->Notify();rn cout<<"-----------------和黄蓉吵架了-----------------"<Detach(o2);rn sub->Notify();rn system("pause");rn return 0;rn[/code]rnrn
struts2的action不能实例化
移动项目,前段用了jquery mobile框架,后端用到了struts2框架。原来访问路径是:http://localhost/login.html,项目可以正常登陆,后来我想让路径变为http://localhost/mobile/login.html,所以在maven的配置里面加上了rnrn/mobilernrn登陆页面可以访问到,路径是:http://localhost/mobile/login.html。rn前台页面发送的是ajax请求到后台。但是登陆的时候,处理登陆请求那个action不能实例化了,我解决了好久,不知道出了什么问题啊,求指教,或者给点解决的思路。类名包名没写错的,因为没改之前是可以的。
不能实例化抽象类什么意思
IMPLEMENT_DYNCREATE(COrderView, CRecordView)rn问题的代码rnrnH文件rn[code=C/C++]#pragma oncernrnclass COrderSet;rnclass CDBSampleDoc;rnrnclass COrderView:public CRecordViewrnrn DECLARE_DYNCREATE(COrderView)rnrnprotected:rn virtual ~COrderView()rn virtual void DoDataExchange(CDataExchange* pDX);rn virtual void OnInitialUpdate();rnrnpublic:rn enum IDD = IDD_ORDERS_FORM ;rn COrderSet* m_pSet;rnrn CDBSampleDoc* GetDocument() constrn rn return reinterpret_cast(m_pDocument);rn rn COrderSet* GetRecordSet();rn COrderView();rnrn#ifdef _DEBUGrn virtual void AssertValid() const;rn virtual void Dump(CDumpContext& dc) const;rn#endifrn;[/code]rnrnCPP文件rn[code=C/C++]#include "stdafx.h"rn#include "DBSample.h"rnrn#include "OrderSet.h"rn#include "DBSampleDoc.h"rn#include "OrderView.h"rnrnIMPLEMENT_DYNCREATE(COrderView, CRecordView)rnrnCOrderView::COrderView()rn : CRecordView(COrderView::IDD),m_pSet(NULL)rnrn rn // TODO: 在此处添加构造代码rnrnrnrnvoid COrderView::DoDataExchange(CDataExchange* pDX)rnrn CRecordView::DoDataExchange(pDX);rn // 可以在此处插入 DDX_Field* 函数以将控件“连接”到数据库字段,例如rn // DDX_FieldText(pDX, IDC_MYEDITBOX, m_pSet->m_szColumn1, m_pSet);rn // DDX_FieldCheck(pDX, IDC_MYCHECKBOX, m_pSet->m_bColumn2, m_pSet);rn // 有关更多信息,请参阅 MSDN 和 ODBC 示例rn DDX_FieldText(pDX,IDC_ORDERID,m_pSet ->m_OrderDetailsOrderID,m_pSet);rn DDX_FieldText(pDX,IDC_CUSTOMERID,m_pSet ->m_OrdersCustomerID,m_pSet);rn DDX_FieldText(pDX,IDC_PRODUCTID,m_pSet ->m_OrderDetailsProductID,m_pSet);rn DDX_FieldText(pDX,IDC_QUANTITY,m_pSet ->m_OrderDetailsQuantity,m_pSet);rn rnrnrnrn#ifdef _DEBUGrnvoid COrderView::AssertValid() constrnrn CRecordView::AssertValid();rnrnrnvoid COrderView::Dump(CDumpContext& dc) constrnrn CRecordView::Dump(dc);rnrn#endifrnrnCOrderset* COrderView::GetRecordset()rnrn ASSERT(m_pSet != NULL);rn return m_pSet;rnrnrnCRecordset* COrderView::OnGetRecordset()rnrn return m_pSet;rn[/code]
CWinThread的派生类不能实例化?
由CWinThread类继承出自己的线程类CMyThread,但为什么CMyThread的构造函数、析构函数全都是protected型?
android不能实例化
logcat是:rnActivityThread.java:1234)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.os.Handler.dispatchMessage(Handler.java:99)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.os.Looper.loop(Looper.java:137)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.app.ActivityThread.main(ActivityThread.java:5041)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at java.lang.reflect.Method.invokeNative(Native Method)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at java.lang.reflect.Method.invoke(Method.java:511)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at dalvik.system.NativeStart.main(Native Method)rn03-20 14:15:15.203: E/AndroidRuntime(8187): Caused by: java.lang.InstantiationException: can't instantiate class com.example.jlsoft.JLsoftView; no empty constructorrn03-20 14:15:15.203: E/AndroidRuntime(8187): at java.lang.Class.newInstanceImpl(Native Method)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at java.lang.Class.newInstance(Class.java:1319)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)rn03-20 14:15:15.203: E/AndroidRuntime(8187): ... 11 morern03-20 14:15:20.283: I/Process(8187): Sending signal. PID: 8187 SIG: 9rn03-20 14:21:52.003: E/Trace(8257): error opening trace file: No such file or directory (2)rn03-20 14:21:53.573: I/Choreographer(8257): Skipped 43 frames! The application may be doing too much work on its main thread.rn03-20 14:21:53.633: D/dalvikvm(8257): newInstance failed: no ()rn03-20 14:21:53.633: D/AndroidRuntime(8257): Shutting down VMrn03-20 14:21:53.643: W/dalvikvm(8257): threadid=1: thread exiting with uncaught exception (group=0x40a71930)rn03-20 14:21:53.733: E/AndroidRuntime(8257): FATAL EXCEPTION: mainrn03-20 14:21:53.733: E/AndroidRuntime(8257): java.lang.RuntimeException: Unable to instantiate activity ComponentInfocom.example.jlsoft/com.example.jlsoft.JLsoftView: java.lang.InstantiationException: can't instantiate class com.example.jlsoft.JLsoftView; no empty constructorrn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.access$600(ActivityThread.java:141)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.os.Handler.dispatchMessage(Handler.java:99)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.os.Looper.loop(Looper.java:137)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.main(ActivityThread.java:5041)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at java.lang.reflect.Method.invokeNative(Native Method)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at java.lang.reflect.Method.invoke(Method.java:511)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at dalvik.system.NativeStart.main(Native Method)rn03-20 14:21:53.733: E/AndroidRuntime(8257): Caused by: java.lang.InstantiationException: can't instantiate class com.example.jlsoft.JLsoftView; no empty constructorrn03-20 14:21:53.733: E/AndroidRuntime(8257): at java.lang.Class.newInstanceImpl(Native Method)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at java.lang.Class.newInstance(Class.java:1319)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)rn03-20 14:21:53.733: E/AndroidRuntime(8257): ... 11 morernActivityThread.java:1234)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.os.Handler.dispatchMessage(Handler.java:99)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.os.Looper.loop(Looper.java:137)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.app.ActivityThread.main(ActivityThread.java:5041)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at java.lang.reflect.Method.invokeNative(Native Method)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at java.lang.reflect.Method.invoke(Method.java:511)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at dalvik.system.NativeStart.main(Native Method)rn03-20 14:15:15.203: E/AndroidRuntime(8187): Caused by: java.lang.InstantiationException: can't instantiate class com.example.jlsoft.JLsoftView; no empty constructorrn03-20 14:15:15.203: E/AndroidRuntime(8187): at java.lang.Class.newInstanceImpl(Native Method)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at java.lang.Class.newInstance(Class.java:1319)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)rn03-20 14:15:15.203: E/AndroidRuntime(8187): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)rn03-20 14:15:15.203: E/AndroidRuntime(8187): ... 11 morern03-20 14:15:20.283: I/Process(8187): Sending signal. PID: 8187 SIG: 9rn03-20 14:21:52.003: E/Trace(8257): error opening trace file: No such file or directory (2)rn03-20 14:21:53.573: I/Choreographer(8257): Skipped 43 frames! The application may be doing too much work on its main thread.rn03-20 14:21:53.633: D/dalvikvm(8257): newInstance failed: no ()rn03-20 14:21:53.633: D/AndroidRuntime(8257): Shutting down VMrn03-20 14:21:53.643: W/dalvikvm(8257): threadid=1: thread exiting with uncaught exception (group=0x40a71930)rn03-20 14:21:53.733: E/AndroidRuntime(8257): FATAL EXCEPTION: mainrn03-20 14:21:53.733: E/AndroidRuntime(8257): java.lang.RuntimeException: Unable to instantiate activity ComponentInfocom.example.jlsoft/com.example.jlsoft.JLsoftView: java.lang.InstantiationException: can't instantiate class com.example.jlsoft.JLsoftView; no empty constructorrn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.access$600(ActivityThread.java:141)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.os.Handler.dispatchMessage(Handler.java:99)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.os.Looper.loop(Looper.java:137)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.main(ActivityThread.java:5041)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at java.lang.reflect.Method.invokeNative(Native Method)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at java.lang.reflect.Method.invoke(Method.java:511)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at dalvik.system.NativeStart.main(Native Method)rn03-20 14:21:53.733: E/AndroidRuntime(8257): Caused by: java.lang.InstantiationException: can't instantiate class com.example.jlsoft.JLsoftView; no empty constructorrn03-20 14:21:53.733: E/AndroidRuntime(8257): at java.lang.Class.newInstanceImpl(Native Method)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at java.lang.Class.newInstance(Class.java:1319)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)rn03-20 14:21:53.733: E/AndroidRuntime(8257): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)rn03-20 14:21:53.733: E/AndroidRuntime(8257): ... 11 morern然后rn出错代码是jlsoftview.javarn我大致知道是can't instantiate class no empty constructorrn 问题是怎么改呢?求指教rnrn
抽象类不能被实例化
  /** * */ package test919; public abstract class Animal { private String name; public Animal(String name) { super(); this.name = name; } public abstract void enjoy(); } package t...
【Debug】不能实例化抽象类
A类继承于B类(抽象类,只有接口),但是没有对B类的接口进行实现,就会提示:不能实例化抽象类。 比如下面的代码: // class IEventParser { virtual void processEvent(int type, std::string json) = 0; virtual void processEvent(int type, std::string json, vo
WebService 接口 不能实例化
在form里引用完调用的时候,发现是个接口,不能实例化。以前没用过 WebServicern请指教
不能实例化抽象类?
我在类中需要用到std::list定义一个成员,rntype只是个基类,这该如何实现?rn
java.io.InputStream 为什么不能实例化
如题
Socket为什么不能实例化?
Socket为什么不能实例化?rn当实例化的时候,就报错
请教:不能实例化水晶报表
老师好:rn 我搞不明白的一个问题:我在vb.net中的一个工程中有一个水晶报表命名为rpt1.rpt。在编码中我写道 dim rpt as new rpt1总是不成功,(在rpt1下有兰道)请问,会在什么地方出现问题呢?rn 谢谢您的指教rnrn 再求教一个问题:如果可以实例化水晶报表,引用该水晶报表中的控件应该怎样写?rn rn 谢谢您的指教
为什么不能实例化?
为什么不能实例化?rnusing System;rnusing System.Web.UI;rnrnnamespace Region.Componentsrnrn public class Root:UserControlrn rn protected RegionContext context = RegionContext.Current;rn protected User user;rn public Root():base()rn rn user = User.OnlineUser;rn rn rnrn rnrnrnrn我写了这么一个类之后,建一个新用户叶面这样(CarDrillEdit.ascx)rnrnpublic class CarDrillEdit : Rootrnrn叶面关闭后就不能打开了,总是提示Root实例化时发生异常!没有对象引用。rnrn也就是说我不能开到设计界面,只能看HTML,cs文件。但是可以编译运行。rnrn这个问题怎么办?rn
对话框类不能实例化
我新建了一个对话框类CMyDlg,基于CDialogrn然后在CMyView里面调用:rnCMyDlg dlg;rnCString strTmp;rndlg.DoModal();rndlg.m_Combol.GetWindowTextA(strTmp);rn...rn运行出现问题,rn跟踪发现把断点设在 dlg.m_Combol.GetWindowTextA(strTmp);rn发现dlg的m_hWnd=00000000;rn也就是没有分配内存,rn请问这是由什么引起的?以前没有遇到过这样的问题!
怎样解决不能实例化?
我写的一个多线程的socket通信,客户端程序run java applet总是说无法实例化,但是作为java appllication 是成功连接的,请问这是为什么?源程序如下:rnimport java.applet.*;rnimport java.awt.*;rnimport java.awt.event.*;rnimport java.io.*;rnimport java.net.*;rnrnpublic class Client extends Panelrnrn //界面设计和添加事件响应rn private TextField tf = new TextField();//文本输入框rn private TextArea ta = new TextArea();//聊天记录窗口rn private Socket socket;rn private DataOutputStream dout;rn private DataInputStream din;rnrnrnrn public Client( String host, int port ) rnrn setLayout( new BorderLayout() );rn add( "North", tf );rn add( "Center", ta );rnrn tf.addActionListener( new ActionListener() rn public void actionPerformed( ActionEvent e ) rn processMessage( e.getActionCommand() );rn rn );rnrnrn //敲回车键以后,与服务器进行连接rn try rnrn socket = new Socket( host, port );rn System.out.println( "connected to "+socket );rnrn din = new DataInputStream( socket.getInputStream() );rn dout = new DataOutputStream( socket.getOutputStream() );rn run();rn // 启动一个消息接收的线程rn // new Thread( this ).start();rn catch( IOException ie ) System.out.println( ie ); rn rnrn // 接收键盘输入并发送消息rn private void processMessage( String message ) rn try rn dout.writeUTF( message );rnrn tf.setText( "" );rn catch( IOException ie ) System.out.println( ie ); rn rnrn // 在另一个窗口显示聊天消息rn public void run() rn try rn while (true) rnrn String message = din.readUTF();rn ta.append( message+"\n" );rn rn catch( IOException ie ) System.out.println( ie ); rn rnrnstatic public void main( String args[] ) throws Exception rn String host = "202.197.111.196" ;rnrnint port=9000;rnrn new Client( host, port ) ;rnrn rnrnrn
类为什么不能实例化??
我在编一个有关XML的程序时在实例化一个类时显示如下信息rn到底是怎么回事?rnrncannot instantiate abstract class due to following members:rnrnlong __stdcall MSXML2::ISAXContentHandler::startPrefixMapping(unsigned short *,int,unsigned short *,int)' : pure virtual function was not definedrnrn出错的地方rn DNContent * pMc = new DNContent();
ActiveX控件不能实例化
ActiveX控件不能实例化的原因有哪些?小弟刚刚接触这方面的知识,自己做了在VC环境下开发了一个控件,能够运行,,但不能实例化,,很着急,,各位高手帮帮忙,,一般的不能实例化的原因都有哪些呢???谢谢……
相关热词 c#检测非法字符 c#双屏截图 c#中怎么关闭线程 c# 显示服务器上的图片 api嵌入窗口 c# c# 控制网页 c# encrypt c#微信网页版登录 c# login 居中 c# 考试软件