小编Rob*_*obᵩ的帖子

从.txt文件中读取数据并保存到矢量

这是一个非常简单的问题:如何读取.txt文件并使用c ++保存到向量?我将9个数据存储在由tab分隔的txt文件中,我想将其保存到三个不同的Vector(我使用的是Eigen库).9个数据是这样的:

 -468.01    198.74  -123.9  -471.67 195.41  46.878  -471.39 111.84  45.518 
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?提前致谢!

c++

-1
推荐指数
1
解决办法
7256
查看次数

为什么这个程序不起作用?

这是我的语法.我试图显示这些值的平均值.它一直给我一个错误,上面写着:错误C2064:术语不评估函数.

这是我的代码:

#include <iostream.h>

int main()

{
  double value;
  double sumofvalue = 0;
  int numberofvalues = 0;
  const int sentinel = 0;
  while(value!=sentinel){
    cout << "Enter a value (0 to quit): ";
    cin >> value;
    numberofvalues++;
    sumofvalue+=value;
  }
  cout << "Average is "((sumofvalue)/(numberofvalues));

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ jgrasp

-1
推荐指数
1
解决办法
89
查看次数

<Method>不是<Class>的成员

这是我以前做过的非常基本的事情,但我不明白为什么我现在遇到问题.我正在创建一个对象'foo',以便与文件中的iostream活动轻松连接.

直到今天我添加了几个似乎在定义文件的上下文中找到问题的方法,我几乎没有构建整个项目.

foo.h中:

    #ifndef FOO_H
    #define FOO_H

    #include <string>
    #include <fstream>
    #include <vector>

    using std::string;
    using std::fstream;
    using std::vector;

    namespace FileSys
    {
        class foo
        {
        public:
            foo();
            /**
             * Attempts to open a file from directory dir
             * @param dir
             *              The path of the file to be opened
             */
            foo( string dir );
            /**
             * Attempts to find a directory using the parent file's path as the root directory and extending the directory by the child string
             * If …
Run Code Online (Sandbox Code Playgroud)

c++ visual-c++

-2
推荐指数
1
解决办法
9758
查看次数

-4
推荐指数
2
解决办法
763
查看次数

无法从函数 Python 调用函数

我来自 Java 和 C# 背景并学习 Python。我想知道为什么这段代码在 pycharm 中给我一个错误说

    Unresolved Reference 'methodA'
Run Code Online (Sandbox Code Playgroud)

用这个代码

    def a():
        print("hi")

    def b():
        a()
Run Code Online (Sandbox Code Playgroud)

python pycharm python-3.x

-5
推荐指数
1
解决办法
5349
查看次数

标签 统计

c++ ×4

jgrasp ×1

pycharm ×1

python ×1

python-3.x ×1

visual-c++ ×1