我写了一个代码(c ++,visual studio 2010),它有一个向量,即使我虽然声明了复制const,但仍然显示未声明复制const
这里的代码
#include<iostream>
#include<vector>
using namespace std;
class A
{
public:
A() { cout << "Default A is acting" << endl ; }
A(A &a) { cout << "Copy Constructor of A is acting" << endl ; }
};
int main()
{
A a;
A b=a;
vector<A> nothing;
nothing.push_back(a);
int n;
cin >> n;
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
错误1错误C2558:类'A':没有可用的复制构造函数或复制构造函数被声明为'显式'c:\ program files\microsoft visual studio 10.0\vc\include\xmemory 48 1删除
有人请帮帮我
我目前正在用Qt编写代码.如何静态编译代码?
从Qt文档中我开始了解以下步骤
1)Visual Studio 2008 - > commandPrompt - > QtDir - > configure -static - > nmake
但是,它需要17 GB,最后它在完成之前退出,说"空间不够".
有没有简单的方法将Qt应用程序编译为独立程序?
我试图这样做,但我没有找到任何方法.我问这个是因为我是Windows的新手.我试过stl-strings,但是visual studio 2008-在stl-wstring-handling中积累了bug.在其他问题上,我稍后会对此事说很多.现在有人可以解释这个问题吗?
我正在尝试学习|| Qt中的代码openGL.我做了一个显示两个数字的应用程序.一个是三角形"A",另一个三角形"B"与"A"相同,只是它围绕z轴旋转了-90度(z轴垂直于计算机屏幕).现在,问题是轮换使维度发生变化.我发布下面的"main.cpp",
#include <QApplication>
#include <QHBoxLayout>
#include <QMessageBox>
#include <QtOpenGL/QGLWidget>
#include <QWidget>
class MyOpenGL:public QGLWidget
{
public:
MyOpenGL(QWidget * parent);
~MyOpenGL();
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
};
MyOpenGL::MyOpenGL(QWidget *parent):QGLWidget(QGLFormat(QGL::SampleBuffers),parent)
{
setAutoFillBackground(false);
}
MyOpenGL::~MyOpenGL()
{
}
void MyOpenGL::initializeGL()
{
glShadeModel(GL_SMOOTH);
glClearColor(0.0f,0.0f,0.0f,0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
}
void MyOpenGL::resizeGL(int w, int h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,width()/height(),10.0f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void MyOpenGL::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
//glTranslatef(0.0,0.0,-10.0);
glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-1.0f,0.0f,-10.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(1.0f,0.0f,-10.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(0.0f,4.0f,-10.0f);
glEnd();
glRotatef(90.0,0.0f,0.0f,-1.0f);
glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-1.0f,0.0f,-10.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(1.0f,0.0f,-10.0f); …Run Code Online (Sandbox Code Playgroud) 我想在Qt-openGL中创建一个应用程序.在这里,我必须根据鼠标点击知道点击的对象.我的想法是存储点(QWidget中的对象区域),并将鼠标点击与这些点匹配.任何人都可以说如何做到这一点?或者任何身体能否以任何其他方式展示?
我正在为应用程序构建一个附件。客户需要付费查看一些网页并从中下载一些文件。他们希望通过加载项自动执行此下载过程。因此,他们不必单击“另存为”并等待下载完成,而是可以单击加载项而忽略该过程。问题是,网页正在向浏览器提供一些cookie。因此,最好的方法是File->“另存页面为”。我想通过附加组件来完成。是否有任何使用firefox-javascript的方法?我使用了nsiDownloader。但是它只保存html,而不保存图片等。有人可以指导我解决这个问题吗?
编辑: 嗨,这是完成欺骗的代码,这要归功于sai prasad
var dir =Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
dir.initWithPath("C:\\filename");
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("C:\\filename.html");
var wbp = Components.classes['@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
.createInstance(Components.interfaces.nsIWebBrowserPersist);
alert("going to save");
wbp.saveDocument(content.document, file,dir, null, null, null);
alert("saved");
Run Code Online (Sandbox Code Playgroud)
编辑: 但是,仍然有些网页没有完全保存为“另存为”。那些保存的页面不像原始页面那样呈现,它们看起来像一些html示例。
我两天前参加了一次面试.受访的人在C++方面表现很好,但在多线程方面则不然.当他让我为两个线程的多线程编写代码时,其中一个线程打印1,3,5,...和另一个打印2,4,6,... 但是,输出应该是1,2,3,4,5,....所以,我给出了下面的代码(sudo代码)
mutex_Lock LOCK;
int last=2;
int last_Value = 0;
void function_Thread_1()
{
while(1)
{
mutex_Lock(&LOCK);
if(last == 2)
{
cout << ++last_Value << endl;
last = 1;
}
mutex_Unlock(&LOCK);
}
}
void function_Thread_2()
{
while(1)
{
mutex_Lock(&LOCK);
if(last == 1)
{
cout << ++last_Value << endl;
last = 2;
}
mutex_Unlock(&LOCK);
}
}
Run Code Online (Sandbox Code Playgroud)
在此之后,他说"即使没有这些锁,这些线程也能正常工作.这些锁定会降低效率".我的观点是没有锁定会有一个线程将检查(last == 1或2)同时另一个线程将尝试将值更改为2或1的情况.所以,我的结论是它将没有锁定,但这不是一个正确/标准的方式.现在,我想知道谁是正确的,在哪个基础上?
我正在制作一个使用QTableWidget的项目.当我试图让它接受滴剂时,我开始知道它不像我想的那样表现.问题是,如果我将QTableWidget更改为QWidget,那么drop就被接受了.所以,问题不在于编码.这里是代码,至于我所关心的问题是在"MyDropWidget"类中
#include <QMouseEvent>
#include <QWidget>
#include <QMessageBox>
#include <math.h>
#include <QApplication>
#include <QPainter>
#include <sstream>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QLabel>
#include <QPaintEvent>
#include <QTableWidget>
#define RADIUS 2
#define DISTANCE_BETWEEN_OBJECTS 2
#define DASH_RECT_HALF_WIDTH 2
#include <QHeaderView>
#include <QPainter>
#include <QHBoxLayout>
#include <QWidget>
#include <QApplication>
class MyMessageBox:public QMessageBox
{
public:
MyMessageBox(std::string message,QWidget *parent=0):QMessageBox(QMessageBox::NoIcon,QString("ErrorMessage"),QString(message.c_str()),QMessageBox::Ok,parent,Qt::Widget)
{
}
};
class MyDragWidget:public QWidget
{
private:
QPoint * start_Pos;
QPixmap drag_Pixmap;
public:
MyDragWidget(QWidget * parent);
private:
void mousePressEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent * event);
void mouseMoveEvent(QMouseEvent …Run Code Online (Sandbox Code Playgroud) 不,这不是那种基本问题.我正在做一个应用程序并得到一个类似的场景,文件将被下载然后它将被上传到FTP服务器,然后本地副本将被删除,然后一个条目将被放置在该文件名的字典中.所以,代码如下
public void download_This_WebPage(string url, string cookies_String, string local_Saving_File_Name_With_Path)
{
WebClient wb = new WebClient();
wb.Headers.Add(HttpRequestHeader.Cookie, cookies_String);
// Below I want to pass this local_File _Path to the event handler
wb.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wb,);
wb.DownloadFileAsync(new Uri(url), local_Saving_File_Name_With_Path + ".html");
}
public void data_Download_Completed(Object sender, System.ComponentModel.AsyncCompletedEventArgs args)
{
//use the file name to upload the file to FTP
}
public FTP_Completed
{
// Delete the file
}
Run Code Online (Sandbox Code Playgroud)
但是,我不知道如何将该文件名传递给download_Completed的事件处理程序.任何人都可以指导我
编辑: 感谢"Darin"和"Frederic"的答案.是否有任何通用的方法将自定义数据传递给(已定义的)事件处理程序,如下所示
void main_Fn()
{
string my_Data = "Data";
some_object a = new …Run Code Online (Sandbox Code Playgroud) 我试图得到CheckedListBox.CheckedItems一个StringList.但我不知道如何得到它.我试图使用LINQ作为一个班轮.我在.Net-C#中的经验不足,无法做到这一点.谁能说怎么做?
注意:我使用的是.Net-4.0.