簡體   English   中英

如何修復 C++ 中預期分號的錯誤?

[英]How to fix Error on expected semicolon in c++?

有人可以幫我解決這個錯誤嗎? 它總是返回錯誤(如問題中所述)。 我是 C++ 的初學者,任何幫助將不勝感激。 提前致謝

編輯:

這是包括

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <iostream>
#include <iterator>


 std::istringstream rows(input);
 std::vector<row> data{std::istream_iterator<row>(rows),std::istream_iterator<row>()}; //the error occurs on this line
 std::cout << table(data);

編輯2:

結構表的代碼

struct table {
    table(std::vector<row> const &r) :t(r) { }
    std::vector<row> const &t;

    friend std::ostream &operator<<(std::ostream &os, table const &t) {
        os << "<table>";
        std::copy(t.t.begin(), t.t.end(), std::ostream_iterator<row>(os));
        return os << "</table>";
    }
};

那不應該是初始化列表,看看更改為()幫助。

std::vector<row> data(std::istream_iterator<row>(rows),std::istream_iterator<row>());

現在您正在調用帶有一對迭代器的構造函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM