简体   繁体   中英

How to fix Error on expected semicolon in c++?

Can Someone help me to fix this error? It always returns the error (as mentioned in the question). I am beginner in c++ and any help will be appreciated. Thanks in Advance

EDIT:

THIS IS THE INCLUDES

#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);

EDIT2:

Code for struct table

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>";
    }
};

That should not be an initializer list, see if changing to () helps.

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

Now you are calling the constructor which takes a pair of iterators.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM