我得到了成员变量'objectCount'的资格错误.编译器还返回'ISO C++禁止非const静态成员的类内初始化'.这是主要类:
#include <iostream>
#include "Tree.h"
using namespace std;
int main()
{
Tree oak;
Tree elm;
Tree pine;
cout << "**********\noak: " << oak.getObjectCount()<< endl;
cout << "**********\nelm: " << elm.getObjectCount()<< endl;
cout << "**********\npine: " << pine.getObjectCount()<< endl;
}
Run Code Online (Sandbox Code Playgroud)
这是包含非const静态objectCount的树类:
#ifndef TREE_H_INCLUDED
#define TREE_H_INCLUDED
class Tree
{
private:
static int objectCount;
public:
Tree()
{
objectCount++;
}
int getObjectCount() const
{
return objectCount;
}
int Tree::objectCount = 0;
}
#endif // TREE_H_INCLUDED
Run Code Online (Sandbox Code Playgroud) 我试图插入以下值
('PA', 'Hilda Blainwood', 3, 10.7, 4308.20, '9/8/1974', '9:00', '07/03/1996 10:30:00');
Run Code Online (Sandbox Code Playgroud)
具有以下结构的表alltypes
create table alltypes( state CHAR(2), name CHAR(30), children INTEGER, distance FLOAT,
budget NUMERIC(16,2), checkin TIME, started TIMESTAMP);
Run Code Online (Sandbox Code Playgroud)
弹出以下错误
test=# insert into alltypes VALUES('PA', 'Hilda Blainwood', 3, 10.7, 4308.20, '9/8/1974',
'9:00', '07/03/1996 10:30:00');
ERROR: INSERT has more expressions than target columns
LINE 1: ...Blainwood', 3, 10.7, 4308.20, '9/8/1974', '9:00', '07/03/199...
Run Code Online (Sandbox Code Playgroud) 我试图绘制一些使用libgdx调试的行,但我失败了.这是我的代码
public class MainMenu extends Screen implements InputProcessor {
private OrthographicCamera camera;
SpriteBatch myBatch;
ShapeRenderer shapeDebugger;
public MainMenu(Game game) {
super(game);
camera= new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.update();}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
myBatch.begin();
stage.draw();
Gdx.gl10.glLineWidth(10);
shapeDebugger.setProjectionMatrix(camera.combined);
shapeDebugger.begin(ShapeType.Line);
shapeDebugger.setColor(1, 1, 1, 1);
shapeDebugger.line(2, 2, 5, 5);
myBatch.end();
}
}
Run Code Online (Sandbox Code Playgroud)
我从行中得到一个错误
shapeDebugger.setProjectionMatrix(camera.combined);
@ Pranav008
非常感谢你.我没想到我需要启动它.但我有一个真正的问题.我将这条线画到游戏画面的中心.
Gdx.gl10.glLineWidth(2);
shapeDebugger.setProjectionMatrix(camera.combined);
shapeDebugger.begin(ShapeType.Line);
shapeDebugger.setColor(1, 1, 1, 1);
shapeDebugger.line(Gdx.graphics.getWidth()/2, 0,Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight());
shapeDebugger.end();
Run Code Online (Sandbox Code Playgroud)
当我尝试调整屏幕大小时,它不会更新到中心,它会向远处移动.
#include <iostream>
#include <iomanip>
using namespace std;
double distance(double, double);
int main ()
{
double rate, time, distanceValue;
cout << fixed << showpoint << setprecision(1);
cout << "Enter rate" << endl;
cin >> rate;
cout << "Enter time" << endl;
cin >> time;
distanceValue = distance(rate, time);
cout << "The distance is " << distanceValue << endl;
}
double distance (double num1, double num2)
{
return num1 * num2;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译它时,我看到一长串错误,我没有错在这里!如果我将方法从double更改为int值,它也可以正常工作!! 为什么??
以下错误:
*> C:\ Users\kifcaliph\Desktop\starting
out with c ++\Chapter6> …