我一直想尝试javascript一段时间,但我希望它是"面向对象的"所以我试图在不同的文件中创建不同的javascript类并尝试创建一个对象并在不同的文件中调用它的方法功能,但它似乎不起作用.
这是我到目前为止:
function Person(name, age, gender)
{
this.age = age;
this.name = name;
this.gender = gender;
this.job;
this.setJob = function(job)
{
this.job = job;
}
this.getAge = function()
{
return this.age;
}
this.getName = function()
{
return this.name;
}
this.getGender = function()
{
return this.gender;
}
}
Run Code Online (Sandbox Code Playgroud)
function Job(title)
{
this.title = title;
this.description;
this.setDescription = function(description)
{
this.description = description;
}
}
Run Code Online (Sandbox Code Playgroud)
function main()
{
var employee = new Person("Richard", 23, male);
document.getElementById("mainBody").innerHTML = employee.getName();
} …Run Code Online (Sandbox Code Playgroud) 我被告知,如果我有多个指针指向同一个对象,我无法正常删除它(使用delete关键字).相反,我被告知我需要将指针设置为NULL或0.
鉴于我有:
ClassA* object = new ClassA();
ClassA* pointer1 = object;
ClassA* pointer2 = object;
Run Code Online (Sandbox Code Playgroud)
所以要delete pointer1和pointer2,我需要做到以下几点?
pointer1 = 0;
pointer2 = 0:
Run Code Online (Sandbox Code Playgroud)
一旦我将其设置为NULL,我还需要使用关键字delete吗?或者只是将它设置为0足够好?
我希望有人可以帮我解决这个小问题,因为我根本就没有.首先,继承代码:
#include<string>
#include<iostream>
#include<Windows.h>
using namespace std;
extern "C"
{
#include<hidsdi.h>
#include<SetupAPI.h>
}
int main()
{
int iQuit;
cout << "Testing Program" << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它不会让我使用std的东西(即cout,cin,endl等).当我取出所有外部"C"代码时,它只允许我使用它......为什么会这样?有没有办法解决这个问题?
编辑:对不起,忘了告诉你确切的错误:它说标识符"cout"未定义
谢谢
有人可以看看我做得对吗请:
//DeviceManager.h
#include <windows.h>
//#include <hidsdi.h>
#include <setupapi.h>
#include <iostream>
#include <cfgmgr32.h>
#include <tchar.h>
#include <devpkey.h>
extern "C"{
#include <hidsdi.h>
}
//#pragma comment (lib, "setupapi.lib")
class DeviceManager
{
public:
DeviceManager();
~DeviceManager();
void ListAllDevices();
void GetDevice(std::string vid, std::string pid);
HANDLE PSMove;
byte reportBuffer;
private:
HDEVINFO deviceInfoSet; //A list of all the devices
SP_DEVINFO_DATA deviceInfoData; //A device from deviceInfoSet
SP_DEVICE_INTERFACE_DATA deviceInterfaceData;
SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailedData;
};
//DeviceManager.cpp
#include"DeviceManager.h"
DeviceManager::DeviceManager()
{
deviceInfoSet = SetupDiGetClassDevs(NULL, TEXT("USB"), NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES); //Gets all Devices
}
DeviceManager::~DeviceManager()
{
}
void …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
#pragma once
class Matrix{
public:
Matrix();
~Matrix();
protected:
float mat[3] = {0.0, 0.0, 0.0};
};
Run Code Online (Sandbox Code Playgroud)
但我收到了错误float mat[3] = {0.0, 0.0, 0.0};.它说错误C2059:语法错误:'{'和错误C2334:'{'之前的意外标记; 跳过明显的功能体.
我正确地创建了数组吗?那有什么问题呢?
我正在构建一个控制台应用程序,该应用程序基本上只是调用数据库的存储过程。这可以正常工作,但是现在我遇到了这个小问题-错误处理。
我正在使用Serilog记录我在文本文件中遇到的所有错误,但是与此相关的问题是,我必须在所有地方都进行尝试捕获。当然,对于一个小的软件来说,使用并放置try-catch并不麻烦,但是在构建大型软件时,我想您有时可能会忘记输入错误处理代码?所以我想知道是否有一种方法可以告诉Serilog,只要有默认设置,就可以记录并打印错误?
任何想法/解决方案将不胜感激。
谢谢
我的应用上线已经快一周了,但我的实时 Google 广告根本没有展示。
我已经尝试仔细检查我能想到的所有内容,例如确保 App ID 和 Ad ID 正确无误,但我对它们并不走运。
我有以下两个功能来加载和显示广告
public func loadAd() {
interstitial = GADInterstitial(adUnitID: "ca-app-pub-3228561607874346/1546949023") //Live Ad 2
let request = GADRequest()
interstitial.load(request)
}
public func showAd() {
if (interstitial.isReady) {
interstitial.present(fromRootViewController: self)
loadAd()
} else {
print("Ad wasn't ready")
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用 Google 教程页面上提供给我的测试广告 ID 来运行测试广告,这似乎运行良好,只是我的实时广告不行。
唯一标记或引起我注意的是控制台正在打印:
[I-ACS023136] 配置没有有效的 Google App ID。
和
[I-ACS034010] 交易失败
但就像我说的,我在 info.plist 文件中仔细检查了我的配置,一切似乎都很好。
有超过 200 个请求和 0% 的匹配率。我只是不知道它可能是什么。
我在我的电脑上插入了一个USB摄像头(使用Windows 7),我正在尝试创建一个程序来从摄像头流式传输图像.
我该怎么做呢?我有相机的VID和PID,但对此却一无所知.请帮忙.
谢谢
我在一个文件中有以下代码,但它似乎不起作用.
我基本上试图创建一个对象,并尝试简单地调用对象的功能并显示它,它不会这样做,我不知道为什么.
var mice = new Mice(10, 10);
function Mice(posX, posY)
{
this.x = posX;
this.y = posY;
this.moveLeft = function ()
{
this.x = x - 1;
}
this.moveRight = function ()
{
this.x = x + 1;
}
this.getXPos = function ()
{
return this.x;
}
}
document.onkeydown = function(e)
{
//document.getElementById("mainBody").innerHTML = e.keyCode;
switch(e.keyCode)
{
case 37:
//document.getElementById("mainBody").innerHTML = "you have pressed left";
mice.moveLeft();
document.getElementById("mainBody").innerHTML = mice.getXPos();
break;
default:
//do nothing
break;
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助尝试使这项工作将不胜感激.
谢谢
我知道这是一个愚蠢的问题,但我似乎无法在网上找到答案。对于引导程序,我知道您使用行和列来指定行的大小。但如果我有这样的事情:
<div class='row'>
<div class='col-md-12'></div>
</div>
Run Code Online (Sandbox Code Playgroud)
添加那个有什么意义col-md-12吗?row如果您想要整排的长度,我认为只要坚持上课就足够了?
对此的任何建议将不胜感激。
谢谢