c++ 偏特化 求解释为什么编译不了?
 #include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#if 0
template< class T>
struct iterator_traits
{
    typedef typename T::iterator_category   iterator_category;
    typedef typename T::value_type      value_type;
    typedef typename T::difference_type difference_type;//表示两迭代器之间的距离
    typedef typename T::pointer     pointer;
    typedef typename T::reference       reference;
};
#endif
template<class T>
class iterator<const T*>
{
    puclic:
    iterator(){cout<<"ok?"<<endl;}
};
int main(void)
{   
     iterator< const int*> ok;
}
0

3个回答

http://www.jb51.net/article/42099.htm

模板类的使用。。。

0
m0_37232228
yu96848 我就是看的那个偏特化才这么写的 感觉和他没差别啊
大约 2 年之前 回复

我就是看的那个偏特化才这么写的 感觉和他没差别啊

0
#include<iostream>
using namespace std;
template<class T>   //声明一个类模板,虚拟类型名为T
class Compare
{
 public:
  Compare(T a,T b)
  {
   x=a;
   y=b;
  }
  T max()
  {
   return(x>y)?x:y;
  }
  T min()
  {
   return(x<y)?x:y;
  }
 private:
  T x,y;
}; 
int main()
{
 Compare <int> cmp1(3,7);  //定义对象cmp1,用于两个整数的比较
 cout<<"Max : "<<cmp1.max()<<endl;
 cout<<"Min : "<<cmp1.min()<<endl<<endl;
  Compare <float> cmp2(45.89,88.76);//定义对象cmp2,用于两个浮点数的比较
 cout<<"Max : "<<cmp2.max()<<endl;
 cout<<"Min : "<<cmp2.min()<<endl;
 Compare <char> cmp3('a','A'); //定义对象cmp3,用于两个字符的比较
 cout<<"Max : "<<cmp3.max()<<endl;
 cout<<"Min : "<<cmp3.min()<<endl;
 return 0; 
}
0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
求解释为什么会这样
下面是dreamweaver的代码rn[color=#0000FF]rnrnrn rn 无标题文档rnrn rnrn 百度搜索rn www.baidu.com百度搜索rn 百度搜索www.baidu.comrnrn[/color]rn我这样写的时候[color=#0000FF]h1:first-childcolor:red; font-size:50px;[/color]不起作用,但是我把[color=#0000FF]百度搜索[/color]给删除掉的话,[color=#0000FF]h1:first-childcolor:red; font-size:50px;[/color]就能起作用,为什么会这样?
为什么运行不了,求解!!!
[code=c]#include rn#include rnrnusing namespace std;rnrnclass MYDATErnpublic:rn const static int td1y;rn const static int td4y;rn const static int td100y;rn const static int td400y;rn const static char dom[12];rn const static short tdom[12];rn const static char* const dowName[7];rn // 星期显示控制标志(默认值false-不显示)rn static bool dowFlag;rn static int Noly(int year);rn static int Dom(int year, int month);rn static int Dow(int year, int month, int day);rn static int Tdoy(int year, int month, int day);rn static long TotalDays(int year, int month, int day);rn static bool IsLeap(int year);rn static bool IsValid(int year, int month, int day);rn MYDATE(int year, int month, int day);rn void TotalDays(int totaldays);rn int TotalDays()const;rn int Tdoy()const;rn int Dow()const;rn void Set(int, int, int);rn void Output() const;rnprivate:rn int year, month, day;rn;rnrnbool MYDATE::dowFlag = false;rnrnconst int MYDATE::td1y = 365;rnrnconst int MYDATE::td4y = 4 * 365 + 1;rnrnconst int MYDATE::td100y = 100 * 365 + 25 - 1;rnrnconst int MYDATE::td400y = 400 * 365 + 100 - 4 + 1;rnrnconst char MYDATE::dom[12] = rn 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31rn;rnrnconst short MYDATE::tdom[12] = rn 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334rn;rnrnconst char* const MYDATE::dowName[7] = rn "星期一","星期二","星期三",rn "星期四","星期五","星期六","星期天"rn;rnrnint MYDATE::Noly(int year)rnrn return year/4 - year/100 + year/400;rnrnrnint MYDATE::Tdoy(int year, int month, int day)rnrn int n = day;rn if(month >= 1 && month <= 12)rn rn n += tdom[month - 1];rn if(month > 2 && IsLeap(year))rn rn n++;rn rn rn return n;rnrnrnlong MYDATE::TotalDays(int year, int month, int day)rnrn long t;rn t = year - 1;rn return t * td1y + Noly(t) + Tdoy(year, month, day);rnrnrnvoid MYDATE::TotalDays(int totaldays)rnrn int n;rn if (totaldays <= 0)rn rn cout << "不正确的参数!\n";rn rn elsern rn year = month = day = 1;rn totaldays --;rnrn // 按400年计算rn n = totaldays / td400y;rn year += n * 400;rn totaldays -= n * td400y;rnrn // 400年内按100年计算rn n = totaldays / td100y;rn if (n > 3) n = 3;rn year += n * 100;rn totaldays -= n * td100y;rnrn // 100年内按4年计算rn n = totaldays / td4y;rn year += n * 4;rn totaldays -= n * td4y;rnrn // 4年内按1年计算rn n = totaldays / td1y;rn if (n > 3) n = 3;rn year += n;rn totaldays -= n * td1y;rnrn // 1年内按月计算rn while (totaldays >= (n = Dom(year, month)))rn rn totaldays -= n;rn month ++;rn rnrn // 1月内按日计算rn day += totaldays;rn rnrnrnint MYDATE::TotalDays() constrnrn int t = year - 1;rn return t * 365 + Noly(t) + Tdoy();rnrnrnint MYDATE::Tdoy() constrnrn int n = tdom[month - 1] + day;rn if (month > 2 && IsLeap(year)) n ++;rn return n;rnrnrnint MYDATE::Dow() constrnrn return TotalDays() % 7;rnrnrnint MYDATE::Dow(int year, int month, int day)rnrn return TotalDays(year, month, day) % 7;rnrnrnint MYDATE::Dom(int year, int month)rnrn int n = 0;rn if(month >= 1 && month <= 12)rn rn n = dom[month - 1];rn if(month == 2 && IsLeap(year))rn rn n++;rn rn rn return n;rnrnrnbool MYDATE::IsLeap(int year)rnrn return year%4 == 0 && year%100 !=0 || year%400 == 0;rnrnrnbool MYDATE::IsValid(int year, int month, int day)rnrn return year > 0 && month >= 1 && month <= 12 && day >= 1 && day <= Dom(year, month);rnrnrnMYDATE::MYDATE(int year, int month, int day)rnrn year = year;rn month = month;rn day = day;rn if(!IsValid(year, month, day))rn rn cout<<"输入的日期不正确!"<year = year;rn this->month = month;rn this->day = day;rn rn elsern rn cout << "不正确的参数!\n";rn rnrnrnvoid MYDATE::Output() constrnrn int w = Dow();rn cout << setfill('0') << setw(4) << year << '-'rn << setw(2) << (short)month << '-'rn << setw(2) << (short)day << setfill(' ');rn if (dowFlag) cout << '(' << dowName[w] << ')';rnrnrnint main()rnrn const MYDATE a(1949, 10, 1);rn cout << "a = "; a.Output(); cout << endl;rn MYDATE::dowFlag = true;rn cout << "a = "; a.Output(); cout << endl;rn MYDATE::dowFlag = false;rn cout << "a = "; a.Output(); cout << endl;rn return 0;rn[/code]rn一运行就弹出错误报告,无法运行,为什么啊?以后碰到类似问题怎么解决啊?
求解释为什么会有error LNK2001
[code=C#]rnrn#includern#includern#includernrnrnrnstruct studrnrn char Name[20];rn float Score;rn struct stud*next;rn;rntypedef struct stud Student;rnrnint GoonDisplay(int i);rnrnint GoonDispaly(int i)rnrn char a;rn if(i==0||i%10!=0)rn rn return 1;rn rn printf("press \'Enter\' to go on: ");rn a=getch();rn if(a='\n')rn rn return 1;rn rn elsern return 2;rnrnvoid Display(Student*head)rnrn static int i=0;rn Student*p=(Student*)malloc(sizeof(Student));rnrn if(head!=NULL)rn rn p=head;rn dorn rn printf("%s\n",&(p->Name));rn printf("%d",&(p->Score));rn p=p->next;rn i++;rn rn whilern (rn (i==0||i%10!=0)&&rn p->next!=NULL&&rn (GoonDisplay(i)==1)rn );rn rnrn printf("No data.\n");rnrnrnint main()rnrn static Student*head=NULL;rn Display(head);rn return 0;rnrnrn[/code]rnrnrnerror LNK2001: unresolved external symbol "int __cdecl GoonDisplay(int)" (?GoonDisplay@@YAHH@Z)rnfatal error LNK1120: 1 unresolved externals
JSP太大编译不了,求解
有个jsp页面大概100多k,在weblogic8.1.5下无法编译,但是在weblogic9.2下面却可以,求解rn jsp的编译大小跟什么配置有关系,JVM吗?
为什么编译不了
为什么编译不了,所在目录WEB-INF/classes/com/news/rn文件名为newslb.javarnrnpackage com.news;rnrnimport java.sql.*;rnimport java.util.*;rnimport java.io.*;rnimport com.coon.*;rn//查看所有的商品分类rnpublic class newslbrnrn private Connection con;rn //公共方法,获得数据库的连接rn public newslb()rn rn this.con=coon.getConnection();rn rn /**rn *返回商品的所有分类,返回的Collection中包含Category值对象。rn */rn public Collection getAllCategory()throws Exceptionrn rn Statement stmt=con.createStatement();rn ResultSet rst=stmt.executeQuery("select * from newslb");rn Collection ret=new ArrayList();rn while(rst.next())rn rn Category temp=new Category();rn temp.setnewslbname(rst.getString("newslbname"));rn temp.setnewslbch(rst.getString("newslbch"));rn temp.setnewslbe(rst.getString("newslbe"));rn ret.add(temp);rn rn //关闭连接,rst和stmt将自动关闭。rn con.close();rn return ret;rn rn rnrnrnrnrnrn公共连接数据库代码方置于WEB-INF/classes/com/coon/rn文件名为coon.javarnrnpackage com.coon;rnimport java.sql.*;rn//连接数据库的工具类。rnpublic class coonrnrn /**rn *一个静态方法,返回一个数据库的连接。rn *这样达到了对数据库连接统一控制的目的。rn */rn public static Connection getConnection()rn rn Connection con=null;rn String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";rn String SERVANDDB="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev";rn String USER="bn";rn String PWD="bn"; rn tryrn rn rn Class.forName(CLASSFORNAME);rn con = DriverManager.getConnection(SERVANDDB,USER,PWD);rn rn catch(Exception e)rn rn e.printStackTrace();rn rn return con;rn rnrnrnrn数据库连接类(coon.java)可以编译,newslb.java无法编译请问各位高手那里错了谢谢给个详细的解释。(菜鸟问题不要见怪。)
为什么编译不了啊???~~~~
h:\c++\lx_asd\lx_asd.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/Lx_asd.pch': No such file or directoryrn执行 cl.exe 时出错.rn怎么办啊??//那位大哥告诉我啊
为什么编译不了? dev
#include rn#include rnusing namespace std;rnint main()rndouble a;rncin>>a;rncout<
请问为什么编译不了??
我使用JCREATOR编译,上面显示不存在APPLET软件包,所有的变量找不到符号?
为什么编译不了啊?
我在c:\moreservlets下放置了两个文件,ServletUtilities.java和ThreeParams.java;环境变量classpath设置为:.;c:\moreservlets;C:\Program Files\jdk\j2sdk1.4.1_02\lib\tools.jar;C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar;但javac ThreeParams通不过;rnrnrnpackage moreservlets;rnrnimport java.io.*;rnimport javax.servlet.*;rnimport javax.servlet.http.*;rnrnpublic class ThreeParams extends HttpServlet rnrn public void doGet (HttpServletRequest request,rn HttpServletResponse response)rn throws ServletException , IOException rn rn response.setContentType ("text/html");rn PrintWriter out = response.getWriter();rn String title = "Reading Three Request Parameters";rn out.println (ServletUtilities.headWithTitle (title) +rn "\n" +rn " " + title + "<1>\n" +rn " \n" +rn " param1: " +rn request.getParameter("param1") + "\n" +rn " param2: " +rn request.getParameter("param2") + "\n" +rn " param3: " +rn request.getParameter("param3") + "\n" +rn "\n" +rn "");rn rn;rnrn________________________________________________rnrnpackage moreservlets;rnrnimport javax.servlet.*;rnimport javax.servlet.http.*;rnrnpublic class ServletUtilitiesrnrn public static final String DOCTYPE =rn "";rn rn public static String headWithTitle (String title) rn return (DOCTYPE + "\n" +rn "\n" +rn " " + title + "\n");rn rn;rnrn
delphi 为什么编译不了?
delphi 5 编译不了,系统提示:debugger kernel bordbk50.dll is missing or not registered.rn经查找,该文件确实存在,请问这个问题如何解决?
xstring 为什么编译不了!
网上下的XString类编译说缺少nodump.h文件和m_pChdata 没标识,这么好的东东不能用,急啊rn哪位大大用过的能告诉我是什么回事吗?100 分rn
请问,为什么编译不了?
rn/* readmail.c */ rnrn#include rn#include rn#include rn#include rn#include rn#include rnrnint readmail();rnrnlong err;rnLHANDLE lhSession;rnlpMapiMessage FAR *lppMessage;rnlpMapiMessage lpMessage;rnchar szSeedMessageID[512];rnchar szMessageID[512];rnchar szTmp[4096];rnchar szTmp2[50];rnrnLPSTR lpszSeedMessageID=&szSeedMessageID[0];rnLPSTR lpszMessageID=&szMessageID[0];rnrnint main()rnrn readmail();rn return(0);rnrnrnrnint readmail()rnrnrnrn /************ Logon **********************/ rn err = MAPILogon(0L, "", "", MAPI_LOGON_UI, 0L,rn &lhSession);rn if(err != SUCCESS_SUCCESS)rn rn MessageBox(0, "Error logging on", "Error", MB_OK);rn return(0);rn rnrn /********* Find Messages ********************/ rn *lpszSeedMessageID = '\0';rnrn // reset MAPIFindNext back to the top againrn err = MAPIFindNext(lhSession, 0L, "IPM.Microsoft Mail.Note",rn lpszSeedMessageID, 0L, 0L, lpszMessageID);rn if(err != SUCCESS_SUCCESS)rn rn MessageBox(0, "Error finding first message", "Error",rn MB_OK);rn err = MAPILogoff(lhSession, 0L, 0L, 0L);rn return(0);rnrnrn rnrn dorn rn lppMessage=(lpMapiMessage FAR *) &lpMessage;rn /******** Read Message *************/ rn err = MAPIReadMail(lhSession, 0L, lpszMessageID,rn MAPI_PEEK, 0L, lppMessage);rn if(err != SUCCESS_SUCCESS)rn rn MessageBox(0, "Error during message read", "Error",rn MB_OK);rn err = MAPILogoff(lhSession, 0L, 0L, 0L);rn return(0);rn rn /******* copy Subject and NoteText into string *************/ rn if((lpMessage->lpszSubject) != NULL)rn _fstrcpy(szTmp2, lpMessage->lpszSubject); // Check for NULL stringsrn rn else _fstrcpy(szTmp2,"No subject text");rn if((lpMessage->lpszNoteText) != NULL)rn if(_fstrlen(lpMessage->lpszNoteText)>4096) // Check for large message bodyrn MessageBox(0, "Message body to large", "MAPI2.C", MB_OK);rn rn _fstrcpy(szTmp, lpMessage->lpszNoteText);rn rn else _fstrcpy(szTmp, "No message body");rn printf("\nSUBJECT: %s\n", szTmp2);rn printf("\nNOTETEXT: \n%s\n", szTmp);rn /****** free memory used by MAPI *********************/ rn err = MAPIFreeBuffer(lpMessage);rn if(err != SUCCESS_SUCCESS)rn rn MessageBox(0, "Error freeing memory", "Error",MB_OK);rn rn //get next message ID.rn lstrcpy(lpszSeedMessageID, lpszMessageID);rn err = MAPIFindNext(lhSession, 0L, "IPM.Microsoft Mail.Note",rn lpszSeedMessageID, 0L, 0L, lpszMessageID);rn if(err != SUCCESS_SUCCESS)rn rn MessageBox(0, "No more messages", "Warning",rn MB_OK);rn err = MAPILogoff(lhSession, 0L, 0L, 0L);rn return(0);rn rn lppMessage=(lpMapiMessage FAR *) &lpMessage;rnrnrn while(err == SUCCESS_SUCCESS);rnrnrn /************** Logoff ***************/ rn err = MAPILogoff(lhSession, 0L, 0L, 0L);rn return(0);rn rnrnrn//====================================================================rn用Dev-C++编译时错误rn [Linker error] undefined reference to `MAPILogon@24' rn [Linker error] undefined reference to `MAPIFindNext@28' rn [Linker error] undefined reference to `MAPILogoff@16' rn [Linker error] undefined reference to `MAPIReadMail@24' rn [Linker error] undefined reference to `MAPILogoff@16' rn [Linker error] undefined reference to `MAPIFreeBuffer@4' rn [Linker error] undefined reference to `MAPIFindNext@28' rn [Linker error] undefined reference to `MAPILogoff@16' rn [Linker error] undefined reference to `MAPILogoff@16' rn ld returned 1 exit status rn C:\Dev-Cpp\project4\Makefile.win [Build Error] [Project4.exe] Error 1
求解释性能
好多人都注重于程序的性能和效率rnrn小弟对于“性能”“效率”这两个词对于程序的理解不够到位,我只单纯的理解为速度,可见这是不对的,求正确点的理解
求解,为什么登录不了也注册不了
我有一个成绩系统源码。 数据库我附加了。然后VS2008打开了这个文件,找到了登陆页面 并运行了。rn 问题就是 我按照他给的 管理员账号密码 登陆, 却提示我 用户名或密码错误。 怎么回事啊
紧急求助,apxs -c *.c -o mod_jserv.so 为什么编译不了
我用的系统 sco unixrn apache1.3.9rn tomcat3.1.1rn jdk1.2.2rn我现在想把apache和tomcat整合,要一mod_jserv.so 但我用rn/usr/internet/apache/bin/apxs -c *.c -o mod_jserv.so,我的路径肯定没错,但unix老提示我/usr/internet/apache/bin/apxs not foundrn我看了一下apxs是存在的,我不知道为什么,我该如何获得呢
为什么vs2003编译不了程序
[img=https://img-bbs.csdn.net/upload/201507/31/1438335860_644885.jpg][/img]
帮我看看 为什么编译不了?
package wht;rnrnimport javax.servlet.*;rnimport javax.servlet.http.*;rnimport com.microsoft.jdbc.sqlserver.SQLServerDriver;rnimport java.sql.*;rnimport java.util.*;rnimport java.io.*;rn//实现对数据库的 插入动作 这是个servlet 打算在表单的action里面提交给它,然后完成rn//可是,编译不过去啊! 我用jsp页面嵌入代码就可以实现,改用servlet为什么不对呢?rnrnrnpublic class InsertServlet extends HttpServletrnrnrnprivate Connection conn;rnrn//构造函数 连接数据库rnrnpublic InsertServlet()rn rn String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";rn String DBURL="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev";rn String USER="sa";rn String PWD="sa"; rn rn rn Class.forName(CLASSFORNAME);rn conn = DriverManager.getConnection(DBURL,USER,PWD);rn rn rnrnrnpublic void doGet(HttpServletRequest request,rn HttpServletResponse response)rn throws IOException, ServletExceptionrn rnrn rn Statement stmt = conn.createStatement();rn String SQLSTR = "insert into myuser(identify_id,reg_id,user_name,user_state,user_pwd,flag values('D1001','5566','com','00','',0)";rn rn stmt.executeUpdate(SQLSTR);rnrn stmt.close();rn conn.close();rnrnrn //end of doGet()rnrn public void doPost(HttpServletRequest request,rn HttpServletResponse response)rn throws IOException,ServletExceptionrn rn doGet(request,response);rn //end of doPost()rn rnrn异常:都是和sql有关系的,可相关的jdbc都装了 classpath也设置了rnInsertServlet.java:25: unreported exception java.lang.ClassNotFoundException; murnst be caught or declared to be thrownrn Class.forName(CLASSFORNAME);rn ^rnInsertServlet.java:26: unreported exception java.sql.SQLException; must be caughrnt or declared to be thrownrn conn = DriverManager.getConnection(DBURL,USER,PWD);rn ^rnInsertServlet.java:37: unreported exception java.sql.SQLException; must be caughrnt or declared to be thrownrn Statement stmt = conn.createStatement();rn ^rnInsertServlet.java:40: unreported exception java.sql.SQLException; must be caughrnt or declared to be thrownrn stmt.executeUpdate(SQLSTR);rn ^rnInsertServlet.java:42: unreported exception java.sql.SQLException; must be caughrnt or declared to be thrownrn stmt.close();rn ^rnInsertServlet.java:43: unreported exception java.sql.SQLException; must be caughrnt or declared to be thrownrn conn.close();rn ^rn6 errors
为什么编译产生不了class文件?
先把事情的来龙去脉跟大家说一下.新建了一个dynamic web project,然后将自己的java文件导入到了JavaSource包里.运行一个jnuit测试的时候,PropertyConfigurator.configure("Log4J.properties")通过不了,报错:java.io.FileNotFoundException: Log4J.properties (系统找不到指定的文件。).rn我改成绝对路径D:\\workspace\\auditLog\\JavaSource\\Log4J.properties就可以通过.这个时候我还没启动tomcat服务器,猜想可能是环境没有运行起来,于是启动服务器,编译,也没有class文件产生,我把output folder设为了auditLog/WebContent/WEB-INF/classes.不知何故产生不了class文件,麻烦大家帮忙
为什么编译不了java文件呢?
请问这是什么原因:rnWebConstants.java文件:rnpackage WebRelease;rnrnpublic interface WebConstantsrnrn public static final String driverClass ="driverClass";rn// const userId is the user id to connect to databasern public static final String userId ="comm";rn// const passWd is the user password to connect to databasern public static final String passWd ="comm123";rn// const url is the url to connect to databasern public static final String url="jdbc:oracle:thin:@127.0.0.1:1521:win";rn public static final String selectType ="select";rn public static final String connection ="connection";rn public static final String connError ="conError";rnrnrnConnectionManager.java文件:rnpackage WebRelease;rnrnimport java.io.*;rnimport java.beans.*;rnimport java.util.*;rnimport java.sql.*;rnimport WebRelease.WebConstants;rnimport oracle.jdbc.driver.*;rnrnpublic class ConnectionManager implements WebConstantsrnrn private boolean debug = true;rn protected Connection con;rn protected DebugWriter writer;rn PropertyChangeSupport pcs;rnrn public ConnectionManager()rn rn pcs = new PropertyChangeSupport(this);rn writer = new DebugWriter();rn rnrn public void setDebug(String b)rn rn debug = b.equals("true");rn rnrnpublic void addPropertyChangeListener( PropertyChangeListener l)rn rn pcs.addPropertyChangeListener(l);rn rnrnpublic void removePropertyChangeListener(PropertyChangeListener l)rn rn pcs.removePropertyChangeListener(l);rn rnrn public void login()rn rn tryrn rn DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());rn Class.forName("oracle.jdbc.driver.OracleDriver");rn rn catch(Exception e)rn rn if(debug) writer.writeDebug("Error setting driver:"+e.getMessage());rn rn tryrn rn con = DriverManager.getConnection(url,userId,passWd);rn pcs.firePropertyChange(connection,null,con);rn if(debug)rn rn writer.writeDebug("connection succeded ! URL:"+url+"User:"+userId+rn "Pwd:"+passWd);rn rn rn catch(Exception e)rn rn pcs.firePropertyChange(connError,null,e);rn if(debug)rn rn writer.writeDebug("connection failed ! URL:"+url+"User:"+userId+rn "Pwd:"+passWd);rn rn rnrn rnrnrn编译时出现如下错误:rn# javac WebConstants.java ConnectionManager.java rnrnConnectionManager.java:16: cannot resolve symbolrnsymbol : class DebugWriter rnlocation: class WebRelease.ConnectionManagerrn protected DebugWriter writer;rn ^rnConnectionManager.java:22: cannot resolve symbolrnsymbol : class DebugWriter rnlocation: class WebRelease.ConnectionManagerrn writer = new DebugWriter();rn ^rn2 errorsrnrnprotected DebugWriter writer 是什么错误呢?rn
NDIS_MINIPORT_CHARACTERISTICS 在VC60为什么编译不了
小弟刚接处NDIS MINIPORT驱动开发,DDK build已经编译过了,试写了一个测试程序,然后VC6.0编译后,所有的MINIPORT函数都编译不了 出现如下错误:rnd:\TestDriver\MyTestDriver\MyTestDriver.cpp(38): error C2065: “NDIS_MINIPORT_CHARACTERISTICS” : 未声明的标识符rnd:\TestDriver\MyTestDriver\MyTestDriver.cpp(38): error C2146: 语法错误 : 缺少“;”(在标识符“MPChar”的前面)rnrnrn#define NDIS50_MINIPORT 1 rn这个也定义,找了很网站都没有关资料rnrn有哪位大虾帮一下rnrn
这个package为什么编译不了?
[code=SQL]rncreate or replace package pack_sunyard_test isrn type refcur is ref cursor;rn/******************************************************************************rn--函数名称: func_sunyard_testrn--作者: sunyard_zhengxlrn--时间: 2007年04月01日rn--使用源表名称: sunyard.tset_a(测试表A)rn sunyard.tset_b(测试表B)rn--目标表明称: rn--参数说明:rn-- i_id (ID值)rn-- o_name (返回NAME值)rn--功能: oracle plsql开发示例-函数rn--解释:rn******************************************************************************/rnfunction func_sunyard_test(rn i_id in number --ID值rn ) rn return varchar2;rn rn/******************************************************************************rn--存储过程名称: proc_sunyard_test1rn--作者: sunyard_zhengxlrn--时间: 2007年04月01日rn--使用源表名称: sunyard.tset_a(测试表A)rn sunyard.tset_b(测试表B)rn--目标表明称: rn--参数说明:rn-- i_id (ID值)rn-- o_name (返回NAME值) rn--功能: oracle plsql开发示例-数据类型、控制结构、调用函数rn--解释:rn******************************************************************************/rnprocedure proc_sunyard_test1(rn i_id in number, --ID值rn o_name out varchar2 --姓名rn );rn rn/******************************************************************************rn--存储过程名称: proc_sunyard_test2rn--作者: sunyard_zhengxlrn--时间: 2007年04月01日rn--使用源表名称: sunyard.tset_a(测试表A)rn sunyard.tset_b(测试表B)rn--目标表明称: rn--参数说明:rn-- i_id (ID值)rn-- o_name (返回NAME值) rn--功能: oracle plsql开发示例-调用过程、游标、游标变量、动态sqlrn--解释:rn******************************************************************************/rnprocedure proc_sunyard_test2(rn i_id in number, --ID值rn o_name out varchar2, --姓名rn o_cur out refcur --游标变量rn );rnend pack_sunyard_test; rn/rncreate or replace package body pack_sunyard_test isrn/******************************************************************************rn--函数名称: func_sunyard_testrn--作者: sunyard_zhengxlrn--时间: 2007年04月01日rn--使用源表名称: sunyard.tset_a(测试表A)rn sunyard.tset_b(测试表B)rn--目标表明称: rn--参数说明:rn-- i_id (ID值)rn-- o_name (返回NAME值)rn--功能: oracle plsql开发示例-函数rn--解释:rn******************************************************************************/rnfunction func_sunyard_test(rn i_id in number --ID值rn ) rn return varchar2 rnisrn v_name varchar2(10); --姓名rn rnbeginrnrn --根据输入的ID查询相应的NAME值rn select a.namern into v_namern from test_a a rn where a.id = i_id;rnrn return v_name;rn rn exceptionrn when others thenrn raise;--抛出异常到调用模块rnend func_sunyard_test;rnrnrnprocedure proc_sunyard_test1(rn i_id in number, --ID值rn o_name out varchar2 --姓名rn ) rnisrn v_code1 number;rn v_code2 number(17,2);rn v_name varchar2(100);rn rnbeginrnrn --number显式或隐式转换成varchar2时会将前面的0转换掉rn v_name := '001';rn v_code1 := v_name;rn rn --控制结构rn if v_name = '001' thenrn v_code1 := 0;rn elsif v_name = '002' thenrn v_code1 := 1;rn else rn v_code1 := -1;rn end if;rn rn case v_namern when '001' then v_code1 := 0;rn when '002' then v_code1 := 1;rn else v_code1 := -1;rn end case;rn rn looprn v_code1 := v_code1 + 1;rn exit when v_code1 > 4;rn end loop;rn rn while v_code1 < 10 looprn v_code1 := v_code1 + 1;rn end loop;rn rn for v_code2 in 1..10 looprn v_code1 := v_code1 + v_code2;rn end loop; rn rn --调用函数rn o_name := func_sunyard_test(i_id);rnrn exceptionrn when others thenrn o_name := sqlcode||'-'||sqlerrm;rn return;rnend proc_sunyard_test1;rnrnrnprocedure proc_sunyard_test2(rn i_id in number, --ID值rn o_name out varchar2, --姓名rn o_cur out refcur --游标变量rn ) rnisrn v_id number;rn v_name varchar2(100);rn v_sql varchar2(2000);rn rn cursor cur_select isrn select a.id,a.name rn from test_a arn where a.id >= 3;rn cursor cursor_select(id number) isrn select a.id,a.name rn from test_a arn where a.id >= id;rn rnbeginrn rn --调用过程rn sunyard.pack_sunyard_test.proc_sunyard_test1(i_id,v_name);rnrn --隐式游标rn select a.namern into v_namern from test_a arn where a.id = i_id;rnrn --小范围异常控制rn begin rn select a.namern into v_namern from test_a arn where a.id = i_id + 1;rn rn exceptionrn when others thenrn v_name := '未匹配';rn return;rn end;rn rn --小技巧rn select nvl(max(a.name),'未匹配')rn into v_name rn from test_a arn where a.id = i_id + 2;rn rn o_name := v_name;rn rn --显式游标rn open cur_select;rn looprn fetch cur_select into v_id,v_name;rn exit when cur_select%notfound;--此行若放到输出语句之后,则会出现重复行rn o_name := to_char(v_id)||'-'||v_name;rn dbms_output.put_line(o_name);rn end loop;rn close cur_select;rn rn --游标for循环rn for c_cur in cursor_select(3) looprn v_id := c_cur.id;rn v_name := c_cur.name;rn o_name := to_char(v_id)||'-'||v_name;rn dbms_output.put_line(o_name);rn end loop;rn rn --游标变量rn v_name := '10000001';rn v_sql := ' select a.code,a.name 'rn ||' from test_a a,test_b b 'rn ||' where a.id = b.id 'rn ||' and a.id < '||i_idrn ||' and a.code != '''||v_name||'''';rn open o_cur for v_sql;rn rn --动态sqlrn v_sql := ' select a.id,a.name 'rn ||' from test_a a 'rn ||' where a.id = '||i_id;rn execute immediate v_sql into v_id,v_name;rn rn v_sql := ' select a.id,a.name 'rn ||' from test_a a 'rn ||' where a.id = :i_id';rn execute immediate v_sql into v_id,v_name using i_id;rn rn --DDL语句rn delete from test_a a where a.id = 10;rn rn update test_a a set a.name = '' where a.id = 11;rn rn insert into test_a(id,code,name,age,address) values(10,'10000010','十',10,'石');rn rn commit;rnrn exceptionrn when others thenrn o_name := sqlcode||'-'||sqlerrm;rn return;rnend proc_sunyard_test2;rnrnend pack_sunyard_test;rn/rnrnrnrnrn[/code]
为什么我的程序编译不了?
我引用了Winsock2,为什么不能运行?
为什么我的Noname3.java编译不了?
[img=https://img-bbs.csdn.net/upload/201409/05/1409925669_118064.png][/img]rn[img=https://img-bbs.csdn.net/upload/201409/05/1409925324_517643.png][/img]rn明明我的public class的名字跟我的文件名相同啊,为什么编译不了?
求解JAVA平台释意——————————
我还搞不清楚平台的确切含义,开发J2EE是JAVA平台,这个平台是指什么呢?rn MS的平台是Windows,和JAVA平台的联系是什么?
编译偏特化代码时,提示"模板 参数“C”与声明不兼容"
[code=c]rn#include rn#include rnrnstruct t1;rnstruct t2;rnstruct t3;rnrn//template struct containerrn// void func(A a1,B a2,C a3)rn// std::cout<<"A: "< struct containerrn void func(A a1,B a2,int a3)rn std::cout<<"specialization"< test1;rn test1.func(x1,x2,index);rnrn std::cout<<"Over"<main1.cpp(23): error C3855: “container”: 模板 参数“C”与声明不兼容rn1>main1.cpp(31): error C2133: “test1”: 未知的大小rn1>main1.cpp(31): error C2512: “container”: 没有合适的默认构造函数可用rn1>main1.cpp(32): error C2662: “container::func”: 不能将“this”指针从“container”转换为“container &”rnrn怎么办?代码写错了还是?求助中!(vs2010+win7)
c语言问题求解释…………
定义和标识符这不懂咋办![图片](https://img-ask.csdn.net/upload/201701/12/1484219612_172903.png)
利用模板偏特化实现编译期断言
利用模板偏特化实现编译期断言断言在C/C++语言中的作用有目共睹,但它只能在运行期起作用,有时可能会希望在编译期检查某个条件,不成立就产生一条编译错误信息,比如你写了一个模板,但是希望模板的参数只能是整数类型,用其它类型对模板进行实例化时干脆让它通不过编译,怎么样,听起来是不是很酷?利用模板的偏特化,轻轻松松就能实作出来,请看:template<bool> compile_assert;templa
子父类继承的问题--求解释为什么运行的结果是03040
package test;rnpublic class Sub extends Super rn int j = 30;rn Sub() rn print();rn j = 40;rn rn void print() rn System.out.print(j);rn rn public static void main(String[] args) rn System.out.print(new Sub().j);rn rnrnclass Super rn int i = 10;rn Super() rn print();rn i = 20;rn rn void print() rn System.out.print(i);rn rn
模版的偏特化
模版的特化与偏特化 模版的特化与偏特化 Partial Template Specialization能够让你在模板(Template)的所有可能的实体中特化出一组子集. 1.模板的特化(template specialization): 例如,定义如下的一个模板: template class Widget { ...
关于链表操作的函数,求解释为什么要创建新的结构体
我是大一新生,才学的Crn这是练习册里的一个工程案例,用于管理学生信息。rnrn先是头文件的部分:rn[code=C/C++]rn#define MES (struct student_message *)malloc(sizeof(struct student_message));rntypedef struct student_messagernrn char name[15];rn int id;rn char sex[7];rn char collage[20];rn int _class;rn struct student_message *next;rnrn MESSAGE;rn[/code]rnrn然后是用于删除链表中一个学生信息的函数rn[code=C/C++]rnMESSAGE *delete_one_stu(MESSAGE *head)rnrn char name[12];rn int id;rn int count,choose;rn char quit;rn MESSAGE *p1,*p2,*search;rn p1=MES;rn p2=MES;rn search=MES;rn if(p1==NULL)rn rn printf("分配内存失败!");rn exit(1);rn rn if(p2==NULL)rn rn printf("分配内存失败!");rn exit(1);rn rn if(search==NULL)rn rn printf("分配内存失败!");rn exit(1);rn rn if(head!=NULL)rn rn p1=head;rn p2=head;rn dorn rn system("cls");rn printf("****************************************\n");rn printf(" 请选择查找方式\n" );rn printf(" 1 姓名\n" );rn printf(" 2 学号\n" );rn printf(" 3 返回\n" );rn printf("****************************************\n");rn printf("请选择:");rn fflush(stdin);rn scanf("%d",choose);rn switch(choose)rn rn case 1:rn search=head;rn printf("请输入需要删除的名字:");rn fflush(stdin);rn gets(name);rn while(search!=NULL)rn rn if(!strcmp(name,search->name))rn rn printf("姓名 学号 性别 学院 班级\n");rn printf("%s %d %s %s %d\n",rn p->name,p->id,p->sex,p->collage,p->_class);rn count++;rn rn search=search->next;rn rn if(count)rn rn printf("是否要删除以上信息(Y/N):");rn fflush(stdin);rn quit=getchar();rn if(quit='y'||quit='Y')rn rn while((p->next!=NULL)&&(strcmp(name,p1->name)))rn rn p2=p1;rn p1=p1->next;rn rn if(!strcmp(name,pi->name))rn rn if(p1==head)rn rn head=p1->next;rn elsern rn p2->next=p1->next;rn rn free(p1);rn rn printf("成功删除!\n");rn rn elsern rn printf("没有所要求删除的姓名!\n");rn rn printf("请按任意键继续...\n");rn getch();rn break;rn case 2:rn search=head;rn printf("请输入需要删除的学号:");rn fflush(stdin);rn scanf("%d",&id);rn while(search!=NULL)rn rn if(id==search->id)rn rn printf("姓名 学号 性别 学院 班级\n");rn printf("%s %d %s %s %d\n",rn p->name,p->id,p->sex,p->collage,p->_class);rn count++;rn rn search=search->next;rn rn if(count)rn rn printf("是否要删除以上信息(Y/N):");rn fflush(stdin);rn quit=getchar();rn if(quit=='y'||quit=='Y')rn rn while((p1->next!=NULL)&&(id!=p1->id))rn rn p2=p1;rn p1=p1->next;rn rn if(id==p1->id)rn rn if(p1==head)rn rn head=p1->next;rn elsern rn p2->next=p1->next;rn rn free(p1);rn rn printf("成功删除!\n");rn rn elsern rn printf("没有您所要删除的信息!\n");rn rn printf("请按任意键继续...\n");rn getch();rn break;rn case 3:rn printf("请按任意键返回...\n");rn getch();rn break;rn default:rn printf("输入错误!\n")rn printf("请按任意键继续...\n");rn getch();rn break;rn rn while(choose!=1&&choose!=2&&choose!=3)rn rn elsern rn printf("信息为空,请先输入信息!\n");rn printf("请按任意键继续...\n");rn getch();rn rn return head;rnrn[/code]rnrnrnrnrn没看懂的地方是函数一开始的一块:rn[code=C/C++]rn p1=MES;rn p2=MES;rn search=MES;rn if(p1==NULL)rn rn printf("分配内存失败!");rn exit(1);rn rn if(p2==NULL)rn rn printf("分配内存失败!");rn exit(1);rn rn if(search==NULL)rn rn printf("分配内存失败!");rn exit(1);rn rnrn[/code]rnrnp1和p2他们是用于记录在链表中位置的变量,为什么还要再开始的时候分配地址?而且还要在分配失败的时候退出函数?rn删除链表中的节点为什么还要开辟新的空间???rn求大牛指导下原理!
类模板(偏特化)
<img src="https://img-bss.csdn.net/201906121145386904.jpg" alt="" />
为什么我的servlet程序运行不了,求解?
就是一个简单的输出“Hello Wrold”的servlet程序。rn首先rn1.所有的servlet程序必须放在WEB目下执行,依靠WEB容器执行rnrn2.servlet本身就是一个类,不需要由主方法调用执行rn3.servle和JavaBean一样,t必须保存在WEB-INF/classes目录中rnrn4.一个类必须继承HttpServlet,那么此类才称为是一个servlet程序rn5.servlet程序必须放在一个包中。。。rn我都按照上面的要求去完成开发环境了:rn代码:是保存在合适的文件路径下了,见图:rnrn[img=http://http://hi.csdn.net/space-793967-do-album-picid-942326-goto-down.html][/img]rn然后就是代码内容:rnpackage org.hjz.servlet;rnimport java.io.*;rnimport javax.servlet.*;rnimport javax.servlet.http.*;rnpublic class HelloServlet extends HttpServletrn public void doGet(HttpServletRequest req,rn HttpServletResponse resp) rn throws ServletException,rn java.io.IOExceptionrn PrintWriter out = null;rn out = resp.getWriter();rn out.println("");rn out.println(" hello</head>");rn out.println("");rn out.println(" ");rn out.println("Hello World!!");rn out.println(" ");rn out.println("");rn out.println("");rn out.close();rn rnrn rnrnrn其中也对它打包了。rn然后就是web.xml的设置rn路径如下图:rn[img=http://http://hi.csdn.net/space-793967-do-album-picid-942325-goto-down.html][/img]rn下面是web.xml修改的代码:rnrn rn hellorn org.hjz.servlet.HelloServletrn rn rn hellorn /hongjunzhirn rnrn这里也对映射进行了设置啊。。为什么浏览器就是没有出现想要的结果呢?rnrn(同学说是路径设置错误了,但是哪里错误了呢?)rnrn
高分求解-COM组件为什么注册不了?
在业务表现层,代码如下:rnrnusing System;rnusing System.Data;rnusing System.EnterpriseServices;rnrnusing WOA.SystemFramework;rnusing WOA.Common;rnusing WOA.Common.Data;rnusing WOA.DataAccess;rnrn[assembly: ApplicationName("WOA.BusinessFacade")]rn[assembly: ApplicationID("C9ED2DCC-1F92-4480-A417-38E07DA8DF8A")]rnrn[assembly: ApplicationActivation(ActivationOption.Library)]rnnamespace WOA.BusinessFacadernrn /// rn /// Summary description for FacadeBase.rn /// rn [Transaction(TransactionOption.Required)]rn public class FacadeBase:ServicedComponentrn rn public FacadeBase()rn rn //rn // TODO: Add constructor logic herern //rn rn rnrnrn其他的class继承与这个class来实现事务。编译没问题,可是运行时出现如下错误:rnrnThe ServicedComponent being invoked is not correctly configured (Use RegSvcs to re-register). rnrn用regsvcs手动注册后,在COM+中出现了所用的组件,但是再次运行,依然有这个问题?
新手求解?ajax为什么提交不了数据
for(i=0; i<3 ;i++)rn (function(i)rn qq.maps.event.addListener(marker,'click',function()rn xmlhttp.open("GET","action.php?Lat=11",true);rn xmlhttp.send();rn location.assign("action.php");rn );rn )(i); rn rnaction.php报错rnNotice: Undefined index: Lat in D:\phpStudy\WWW\traffic\action.php on line 10rn
二叉树问题,求解为什么输出不了
[code=c]rn#includern#includern#includern#includern#includern#includernusing namespace std;rnrntypedef struct Nodernrn rn int data;rn struct Node* LChild;rn struct Node* RChild;rnBiTree;rnrnrnvoid CreateTree(BiTree *t)rnrn int a;rn cin>>a;rn if (a==0)rn rn t=NULL;rn rn else rnrn while(a!=0)rn rn rn rn t=new BiTree;rn t->data=a;rn CreateTree(t->LChild);rn CreateTree(t->RChild); rn rn rn rnrnvoid pri(BiTree *t)rnrn rn rn if(t!=NULL)rn rn cout<data;rn pri(t->LChild);rn pri(t->RChild);rn rnrnrnint main()rnrn BiTree *T=new BiTree; rn rn cout<<"请输入数据,将以完全二叉树形式建立"<data;rn rn return 0;rnrnrn[/code]rnrn网上的也很多都是无法输出的,已经输入cin那里的判定条件
求解:为什么我的背光控制关闭不了
我想实现在开机logo出现之前关闭背光,跟踪代码在OEMPlatformInit()函数里有InitializeDisplay();我在这之前调用了BACKLIGHT_OFF(g_pGPIOReg),来控制背光,但是下载到板子上没反应。求解。
为什么插入不了数据?急求解!!!!
void jButton1_actionPerformed(ActionEvent e) rn //private ReadWriteRow rwr;rn procedureResolver1.setInsertProcedure(new com.borland.dx.sql.dataset.ProcedureDescriptor(database1,rn "insert Customers values ('"+jdbTextField1.getText()+"','"rn +jdbTextField2.getText()+"','"rn +jdbTextField3.getText()+"','"rn +jdbTextField4.getText()+"','"rn +jdbTextArea1.getText()+"')", null, true, Load.ALL));rn rnrn我在按钮上加的这个事件处理函数,可为什么插入数据不成功呢?rn但是程序也没报错信息出现,真要命呢!!!!rn在线等!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
求解 为什么设置不了 控件的属性
protected void IBtnOrderPrice_Command(object sender, CommandEventArgs e)rn rn string name = e.CommandName;rn DataListItem dli = (DataListItem)DL_GameCard.Controls[0];rn System.Diagnostics.Debug.Assert(dli.ItemType == ListItemType.Header);rn ImageButton orderprice = (ImageButton)dli.FindControl("IBtnOrderPrice");rn ImageButton ordername = (ImageButton)dli.FindControl("IBtnOrderName");rn switch (name)rn rn case "Price"://升序rn str_order = "DiscountPrice";rn this.GameCardDataBind("", 1, Paging1.ItemsPerPage, str_order);rn orderprice.CommandName = "Pricedesc";rn orderprice.ImageUrl = "~/images/pricecion1.gif";rn break;rn case "Pricedesc"://降序rn str_order = "DiscountPrice DESC"; rn this.GameCardDataBind("", 1, Paging1.ItemsPerPage, str_order);rn orderprice.CommandName = "Price";rn orderprice.ImageUrl = "~/images/pricecion.gif";rn break;rn case "Name"://升序rn str_order = "Name";rn ordername.CommandName = "Namedesc";rn ordername.ImageUrl = "~/images/namecion1.gif";rn this.GameCardDataBind("", 1, Paging1.ItemsPerPage, str_order);rn break;rn case "Namedesc"://降序rn str_order = "Name DESC";rn ordername.CommandName = "Name";rn ordername.ImageUrl = "~/images/namecion.gif";rn this.GameCardDataBind("", 1, Paging1.ItemsPerPage, str_order);rn break;rn default:rn break;rn rn rnrn我获取了DataList头部控件的值 但是 设置不了 为什么啊
特化与偏特化
一 特化与偏特化 1.1 偏特化        综合STL 源码剖析中给出的两种定义,可以如下定义:所谓偏特化的意思是提供另一份更进一步条件的template定义式,其仍然是模板化的。举一个例子: template&amp;lt;typename T&amp;gt; struct Test{ typedef T value_type; }; // 偏特化版本1 template&amp;lt;typen...
模板,偏特化?
[code=c]rnclass Brnrntemplate rnclass Arnrn[/code]rn现在想做个模板类A,但模板参数只能是B或B类的子类,怎么弄?rn
相关热词 c#异步发送kafka c#窗体编号 c# 操作二进制文件 c# 反射 机制 c#线程 窗体失去响应 c#角度转弧度 c# 解析gps数据 c# vs设置 语法版本 c# json含回车 c#多线程demo