首页 \ 问答 \ vector 让我困惑(vector confuses me)

vector 让我困惑(vector confuses me)

说我需要在我的向量中存储长字符串。 我可以将它声明为矢量。 然而,更好的方法是存储指向这些字符串的指针,而不是实际的字符串。

所以,我的声明应该像矢量一样,我只做以下的事情:

LOOP
//Accept String from a file in myString
vector<string *> v1;
string * sample = &myString;
v1.push_back(sample);
END LOOP

这是否合适或存在更好的方法来实现这一目标? 我甚至可能完全错了。


Say I need to store long strings in my vector. I can declare it as vector. However the better approach would be to store pointers to those strings and not the actual strings.

So should my declaration be something like vector & simply I do something like:

LOOP
//Accept String from a file in myString
vector<string *> v1;
string * sample = &myString;
v1.push_back(sample);
END LOOP

Is this appropriate or their exists a better way to achieve this? I may even be wrong completely out here.


原文:https://stackoverflow.com/questions/11779690
更新时间:2024-04-06 07:04

最满意答案

我一完成输入问题,就意识到自己的错误。

"start"属性不存在时,NPM将使用server.js调用node 。 但我没有server.js 。 NPM会检查此server.js文件,如果不存在则会失败。 理想情况下,NPM应该报告找不到server.js 。 当前处理事物的方式令人困惑。

只要你有一个server.js文件, npm start可以了。


As soon as I finished typing the question, I realized my error.

When "start" property is absent, NPM will invoke node with server.js. But I don't have a server.js. NPM checks under the hood for this server.js file, and fails if it's not present. Ideally though, NPM should have reported that server.js wasn't found. The current way of handling things is confusing.

As soon as you have a server.js file, npm start works fine.

相关问答

更多
  • 看起来您可能没有在package.json文件中定义一个start脚本,或者您的项目不包含server.js文件。 如果包的根目录中有一个server.js文件,那么npm会将start命令默认为node.js。 https://docs.npmjs.com/misc/scripts#default-values 您可以将应用程序脚本的名称更改为server.js或者将以下内容添加到您的package.json "scripts": { "start": "node your-script.js" ...
  • 像你看到错误的部分那样的解构被添加到版本6中的react-scripts似乎依赖于更新的版本,因此更新节点版本可能会解决这个问题。 Deconstruction like the part you see the error in was added to node.js in version 6. react-scripts seems to rely on a newer version, so updating your node version will probably solve this pr ...
  • 我一完成输入问题,就意识到自己的错误。 当"start"属性不存在时,NPM将使用server.js调用node 。 但我没有server.js 。 NPM会检查此server.js文件,如果不存在则会失败。 理想情况下,NPM应该报告找不到server.js 。 当前处理事物的方式令人困惑。 只要你有一个server.js文件, npm start可以了。 As soon as I finished typing the question, I realized my error. When "start ...
  • 你的package.json里面可以添加 "start": "ng serve --open | nodemon node/", 请记住,它与你的package.json位置有关,所以在上面的例子中,节点是我的角度项目中的一个子目录。 这也会为你打开一个浏览器。 如果你不想让浏览器打开,只需删除--open 完整的例子 "scripts": { "ng": "ng", "start": "ng serve --open | nodemon node/", "build": "ng build", "tes ...
  • IBM Node.js buildpack中的App Management目前仅支持使用带有JS文件的node可执行文件启动的应用程序。 例如, node [opts] server.js [args] 这是因为App Management中的许多实用程序依赖于能够操作启动命令。 例如,要启用检查器启动应用程序,我们需要能够设置调试端口( --debug $PORT )。 由于此限制,如果您的应用程序使用gulp或类似的构建自动化系统来启动您的应用程序,则不支持App Management。 App Ma ...
  • 首先保存要在文件中运行的脚本,例如compile.sh 。 为脚本提供正确的运行权限,例如chmod 755 compile.sh 。 然后,在PHP脚本中,添加以下内容:
  • Forever可以为您完成流程管理。 forever start app.js forever stop app.js 尽量避免在开发之外依赖于npm start ,它只是在你和节点之间添加了一个额外的层。 Forever can do the process management stuff for you. forever start app.js forever stop app.js Try to avoid relying on npm start outside of development ...
  • 如果你刚刚开始角度2,那么请按照角度网站上提到的这些步骤。 1从这里下载入门项目。 把它保存到本地文件夹让我们说c:\ test \。 location = https://github.com/angular/quickstart.git quickstart这是你需要为hellp world app做的所有事情。 2)转到命令提示符然后cd c:\ test。 3)如果没有安装,请输入节点js。 4)npm install 5)npm start 这将显示你的第一个有角度的2 hello world应用 ...
  • 你在tsconfig.json有拼写错误。 将moduleResolution更改为moduleResolution 。 You have typo inside tsconfig.json. Change moduleResolutions to moduleResolution.
  • mongoose错误可能是由于mongoose版本不稳定,更新了"mongoose": "3.8" package.json中的"mongoose": "3.8" 。 (后跟npm install )这可能会删除猫鼬警告。 检查此链接是否无法加载c ++扩展 The mongoose error might be due to unstable version of mongoose, update "mongoose": "3.8" in package.json. (Followed by npm in ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。