我是Qt编程的新手,并且遵循了本教程.
在本教程中,地球上有一个复杂的程序,它是这样的:
#include "mainwindow.h"
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication prog(argc, argv);
QLabel *l = new QLabel("Itay's First GUI in C++!!");
l->show();
return prog.exec();
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我得到这些错误:
C:\Users\user-pc\Tutorial\main.cpp:6: error: variable 'QApplication prog' has initializer but incomplete type
QApplication prog(argc, argv);
^
C:\Users\user-pc\Tutorial\main.cpp:10: warning: control reaches end of non-void function [-Wreturn-type]
}
^
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我这个原因吗?
我想确认哪个场景会导致对象myObj上的垃圾收集:
场景1
ArrayList arList = new ArrayList();
while(someCondition)
{
myObj = new MyObect(); // a custom object
arList.add(myObj);
}
Run Code Online (Sandbox Code Playgroud)
情景2
ArrayList arList = new ArrayList();
while(someCondition)
{
myObj = new MyObect(); // a custom object
arList.add(myObj);
myObj=null;
}
Run Code Online (Sandbox Code Playgroud)
将对象显式设置为null可以改善垃圾收集行为,还是在使用新构造函数重置对象时也是如此?
考虑您有"System_A"这是一个Web应用程序.而System_A只有3层:UI,BusinessLayer和数据层.
现在,您希望在作为实时产品工作时对System_A(仅限UI和BusinessLayer)进行广泛的重构.
什么是最安全的策略,重构System_A并在经过良好测试后释放重构产品-let称之为"RF_SystemA" - 即使出现意外错误也可以将其转换为System_A(不强迫用户改变)他们的网址)?
我需要在Java中实现具有多个接口继承的Facade设计模式,或者是具有Bridge设计模式的正确Facade.我知道这是可能的,因为我把它作为一个系统的一部分看到了,但我不记得实现得很好.
这是我到目前为止的实现:
public interface IOne {
public void methodOneIOne();
public void methodTwoIOne();
}
Run Code Online (Sandbox Code Playgroud)
它的实施:
public class One implements IOne {
@Override
public void methodOneIOne() {
System.out.println("methodOneIOne()");
}
@Override
public void methodTwoIOne() {
System.out.println("methodTwoIOne()");
} }
public interface ITwo {
public void methodOneITwo();
public void methodTwoITwo();
}
public class Two implements ITwo {
@Override
public void methodOneITwo() {
System.out.println("methodOneITwo()");
}
@Override
public void methodTwoITwo() {
System.out.println("methodTwoITwo()");
}}
Run Code Online (Sandbox Code Playgroud)
门面:
public interface IFacade extends IOne, ITwo {}
Run Code Online (Sandbox Code Playgroud)
所以,从这里我不知道去哪里.如果我创建一个实现IFacade的类,那么它将需要实现所有方法,这不是我想要的.
int buf1[] = {0,0,0,0,0};
int* buf2 = new int[5]; //assume every element is initialzed to 0 as well
Run Code Online (Sandbox Code Playgroud)
我能想到的唯一区别是buf1是对数组的引用,而buf2是指向数组的指针.换句话说,buf1总是引用数组,而buf2也指向其他地方.
除了上面提到的那个,声明(和初始化数组)的两种方式之间还有什么区别吗?
元素的宽度可变,所以我不知道.
是否可以将此元素置于其包装元素中?
包装纸的固定宽度为960px ......
我正在尝试使用 Clipper 库来扩展我的避障机器人控制任务中的障碍物图像。但是现在,我什至坚持使用库的示例代码:
(http://www.angusj.com/delphi/clipper.php#code)
//from clipper.hpp ...
//typedef signed long long long64;
//struct IntPoint {long64 X; long64 Y;};
//typedef std::vector<IntPoint> Polygon;
//typedef std::vector<Polygon> Polygons;
...
using namespace ClipperLib;
Polygons subj(2), clip(1), solution;
subj[0].push_back(IntPoint(180,200));
subj[0].push_back(IntPoint(260,200));
subj[0].push_back(IntPoint(260,150));
subj[0].push_back(IntPoint(180,150));
subj[1].push_back(IntPoint(215,160));
subj[1].push_back(IntPoint(230,190));
subj[1].push_back(IntPoint(200,190));
clip[0].push_back(IntPoint(190,210));
clip[0].push_back(IntPoint(240,210));
clip[0].push_back(IntPoint(240,130));
clip[0].push_back(IntPoint(190,130));
DrawPolygons(subj, 0x160000FF, 0x600000FF); // <- identifier not found
DrawPolygons(clip, 0x20FFFF00, 0x30FF0000); // <- identifier not found
Clipper c;
c.AddPolygons(subject, ptSubject);
c.AddPolygons(clip, ptClip);
if (c.Execute(ctIntersection, solution)
DrawPolygons(solution, 0x3000FF00, 0xFF006600);
Run Code Online (Sandbox Code Playgroud)
我想知道我是否缺少任何库安装?我知道这是一个小问题,我有点菜鸟,但任何帮助都可以减轻我的很多工作。谢谢!
一个shell脚本:
VAR=(aa bb cc)
for i in "${VAR[@]}"
do
echo $i;
done
Run Code Online (Sandbox Code Playgroud)
使用. ar_test.sh它时,它的工作原理.
zhangyf@zhangyf-desktop:~/test$ . ar_test.sh
aa
bb
cc
Run Code Online (Sandbox Code Playgroud)
但是以这种方式失败了,
zhangyf@zhangyf-desktop:~/test$ ./ar_test.sh
./ar_test.sh: 9: Syntax error: "(" unexpected
Run Code Online (Sandbox Code Playgroud)
文件中还有其他行,因此第9行实际上是VAR =(aa bb cc).我知道不同之处在于后者提出了一个新的shell进程,而前者在当前shell中运行脚本,但为什么结果差异如此之大?
我试图使用CLLocationCoordinate2D获取用户的当前位置.我希望格式的值如
CLLocationCoordinate2D start = {-28.078694,153.382844};
所以我可以使用它们如下:
NSString *urlAddress = [NSString
stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f",
start.latitude, start.longitude,
destination.latitude, destination.longitude];
Run Code Online (Sandbox Code Playgroud)
我用了
CLLocation *location = [[CLLocation alloc]init ];
CLLocationDegrees currentLatitude = location.coordinate.latitude;
CLLocationDegrees currentLongitude = location.coordinate.longitude;
Run Code Online (Sandbox Code Playgroud)
获得当前的lat和long.
但是当我尝试测试时,我得到了0.000.我在iPhone 4s上测试.
如果有任何示例代码,那就太棒了.
我是Java的初学者,需要将Java最终项目的应用程序放在一起.我想做刽子手(当时很容易看见).这对我来说非常困难.到目前为止,这是我的代码.(这真是令人厌恶的大约10个开源刽子手游戏一起抛出).请参阅我的问题的底部.
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.util.ArrayList;
public class Hangman implements ActionListener {
JFrame frame;
private String[] wordList = {"computer","java","activity","alaska","appearance","article",
"automobile","basket","birthday","canada","central","character","chicken","chosen",
"cutting","daily","darkness","diagram","disappear","driving","effort","establish","exact",
"establishment","fifteen","football","foreign","frequently","frighten","function","gradually",
"hurried","identity","importance","impossible","invented","italian","journey","lincoln",
"london","massage","minerals","outer","paint","particles","personal","physical","progress",
"quarter","recognise","replace","rhythm","situation","slightly","steady","stepped",
"strike","successful","sudden","terrible","traffic","unusual","volume","yesterday" };
public String mysteryWord;
public int lives;
private boolean finished = false;
private boolean won = false;
private Button a[];
public boolean used[] = new boolean[26];
public static void main (String[] args) {
Hangman gui = new Hangman();
gui.go();
}
class myDrawPanel extends JPanel {
public void paintComponent(Graphics g) {
setBackground(Color.white); …Run Code Online (Sandbox Code Playgroud)