小编Avi*_*pal的帖子

未明确引用运算符>>

我正在尝试运算符重载,我的头文件包括:

#ifndef PHONENUMBER_H
#define PHONENUMBER_H

#include<iostream>
#include<string>
using namespace std;

class Phonenumber
{
    friend ostream &operator << ( ostream&, const Phonenumber & );
    friend istream &operator >> ( istream&, Phonenumber & );
private:
    string areaCode;
    string exchange;
    string line;

};

#endif // PHONENUMBER_H
Run Code Online (Sandbox Code Playgroud)

和类的定义

//overload stream insertion and extraction operators
//for class Phonenumber
#include <iomanip>
#include "Phonenumber.h"
using namespace std;
//overloades stram insertion operator cannot be a member function
// if we would like to invoke it with
//cout<<somePhonenumber
ostream …
Run Code Online (Sandbox Code Playgroud)

c++ undefined-reference

7
推荐指数
1
解决办法
7675
查看次数

使用Perl从文件中获取数据

我有档案:

<country=HK>

    TCN=1
    CURR_TYPE="RS"
    PRICE=10
    COMP_NAME="IBM"

    TCN=2
    CURR_TYPE="RS"
    PRICE=200
    COMP_NAME="CTS"

    TCN=3
    CURR_TYPE="RS"
    PRICE=50
    COMP_NAME="TCS"


endHK

<country=JN>

    TCN=1
    CURR_TYPE="YEN"
    PRICE=10
    COMP_NAME="IBM"

    TCN=2
    CURR_TYPE="YEN"
    PRICE=200
    COMP_NAME="CTS"

    TCN=3
    CURR_TYPE="YEN"
    PRICE=50
    COMP_NAME="TCS"

</country=JN>
Run Code Online (Sandbox Code Playgroud)

现在我想使用Perl脚本从上面文件中的成员中检索值.

我的Perl脚本文件是:

#!perl

open(FH, "<a.txt");
@a=<FH>;
$b=$#a;
for ($n=0;$n<$b;$n++)
{
    if ($a[$n]=~/HK/)
    {
        foreach $_ ( @a[$n..($n+300)])
        {               
            if($_ =~ /endHK/){ exit 0;}
            print $_;
        }
    }
}

close(FH);
Run Code Online (Sandbox Code Playgroud)

请附加代码以帮助我从上面的文件中检索数据.

perl

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

标签 统计

c++ ×1

perl ×1

undefined-reference ×1